change slider layout
This commit is contained in:
42
src/main.cpp
42
src/main.cpp
@@ -88,37 +88,34 @@ int main(int argc, char **argv)
|
||||
window.resize(800, 600);
|
||||
|
||||
// Create the layout
|
||||
QVBoxLayout *layout = new QVBoxLayout(&window);
|
||||
QGridLayout *layout = new QGridLayout(&window);
|
||||
layout->setColumnStretch(1, 1); // Make the second column (sliders) expand
|
||||
|
||||
// Create the original image label
|
||||
originalImageLabel = new QLabel("Original Image");
|
||||
layout->addWidget(originalImageLabel);
|
||||
layout->addWidget(originalImageLabel, 0, 0, 1, 3); // Span 3 columns
|
||||
|
||||
// Create the result image label
|
||||
resultImageLabel = new QLabel("Result Image");
|
||||
layout->addWidget(resultImageLabel);
|
||||
layout->addWidget(resultImageLabel, 1, 0, 1, 3); // Span 3 columns
|
||||
|
||||
// Create the input image path input field
|
||||
QHBoxLayout *inputLayout = new QHBoxLayout;
|
||||
QLabel *inputLabel = new QLabel("Input Image:");
|
||||
inputImagePathEdit = new QLineEdit;
|
||||
QPushButton *inputBrowseButton = new QPushButton("Browse");
|
||||
QObject::connect(inputBrowseButton, &QPushButton::clicked, openInputImage);
|
||||
inputLayout->addWidget(inputLabel);
|
||||
inputLayout->addWidget(inputImagePathEdit);
|
||||
inputLayout->addWidget(inputBrowseButton);
|
||||
layout->addLayout(inputLayout);
|
||||
layout->addWidget(inputLabel, 2, 0);
|
||||
layout->addWidget(inputImagePathEdit, 2, 1);
|
||||
layout->addWidget(inputBrowseButton, 2, 2);
|
||||
|
||||
// Create the output image path input field
|
||||
QHBoxLayout *outputLayout = new QHBoxLayout;
|
||||
QLabel *outputLabel = new QLabel("Output Image:");
|
||||
outputImagePathEdit = new QLineEdit;
|
||||
QPushButton *outputBrowseButton = new QPushButton("Browse");
|
||||
QObject::connect(outputBrowseButton, &QPushButton::clicked, openOutputImage);
|
||||
outputLayout->addWidget(outputLabel);
|
||||
outputLayout->addWidget(outputImagePathEdit);
|
||||
outputLayout->addWidget(outputBrowseButton);
|
||||
layout->addLayout(outputLayout);
|
||||
layout->addWidget(outputLabel, 3, 0);
|
||||
layout->addWidget(outputImagePathEdit, 3, 1);
|
||||
layout->addWidget(outputBrowseButton, 3, 2);
|
||||
|
||||
// Create the lambda slider
|
||||
QLabel *lambdaLabel = new QLabel("Lambda:");
|
||||
@@ -126,6 +123,9 @@ int main(int argc, char **argv)
|
||||
lambdaSlider->setObjectName("LambdaSlider"); // Set object name for styling
|
||||
lambdaSlider->setMinimum(0);
|
||||
lambdaSlider->setMaximum(100);
|
||||
lambdaSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); // Allow horizontal expansion
|
||||
layout->addWidget(lambdaLabel, 4, 0);
|
||||
layout->addWidget(lambdaSlider, 4, 1);
|
||||
|
||||
// Create the iterations slider
|
||||
QLabel *iterationsLabel = new QLabel("Iterations:");
|
||||
@@ -133,27 +133,23 @@ int main(int argc, char **argv)
|
||||
iterationsSlider->setObjectName("IterationsSlider"); // Set object name for styling
|
||||
iterationsSlider->setMinimum(1);
|
||||
iterationsSlider->setMaximum(100);
|
||||
iterationsSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); // Allow horizontal expansion
|
||||
layout->addWidget(iterationsLabel, 5, 0);
|
||||
layout->addWidget(iterationsSlider, 5, 1);
|
||||
|
||||
// Create labels to display slider values
|
||||
QLabel *lambdaValueLabel = new QLabel();
|
||||
QLabel *iterationsValueLabel = new QLabel();
|
||||
layout->addWidget(lambdaValueLabel, 4, 2);
|
||||
layout->addWidget(iterationsValueLabel, 5, 2);
|
||||
|
||||
// Set stylesheet for dark design
|
||||
QString styleSheet = "QLabel { color: white; }" // Set label text color to white
|
||||
"QSlider::groove:horizontal { background-color: #555555; height: 6px; }" // Set groove color and height
|
||||
"QSlider::handle:horizontal { background-color: #ffffff; width: 10px; margin: -6px 0; }"; // Set handle color and size
|
||||
|
||||
lambdaSlider->setStyleSheet(styleSheet);
|
||||
iterationsSlider->setStyleSheet(styleSheet);
|
||||
|
||||
// Create layout and add widgets
|
||||
layout->addWidget(lambdaLabel);
|
||||
layout->addWidget(lambdaSlider);
|
||||
layout->addWidget(lambdaValueLabel);
|
||||
layout->addWidget(iterationsLabel);
|
||||
layout->addWidget(iterationsSlider);
|
||||
layout->addWidget(iterationsValueLabel);
|
||||
|
||||
// Connect slider value changes to label updates
|
||||
QObject::connect(lambdaSlider, &QSlider::valueChanged, [=](int value)
|
||||
{ lambdaValueLabel->setText(QString::number(value)); });
|
||||
@@ -164,7 +160,7 @@ int main(int argc, char **argv)
|
||||
// Create the denoise button
|
||||
QPushButton *denoiseButton = new QPushButton("Denoise");
|
||||
QObject::connect(denoiseButton, &QPushButton::clicked, updateDenoisedImage);
|
||||
layout->addWidget(denoiseButton);
|
||||
layout->addWidget(denoiseButton, 6, 0, 1, 3); // Span 3 columns
|
||||
|
||||
// Show the main window
|
||||
window.show();
|
||||
|
Reference in New Issue
Block a user