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