Dialog layout spacing issue
Solved
General and Desktop
-
Hello,
how can I remove these huge spaces around HSV pickers and over OK/Cancel buttons?
I tried to change it with
setContentsMargins()
andsetSpacing()
without any success.Thanks a lot!
Win10, Qt5.15.8
void ColorDialog::createLayout() { QVBoxLayout* mainLayout = new QVBoxLayout; QHBoxLayout* hBoxLayout = new QHBoxLayout; QGridLayout* gridLayout = new QGridLayout; hBoxLayout->addWidget(hueSatPicker); hBoxLayout->addWidget(valPicker); gridLayout->addWidget(colorSample, 0, 0, 4, 1); gridLayout->addWidget(new QLabel(tr("Hue")), 0, 1, Qt::AlignRight); gridLayout->addWidget(hueSpinBox, 0, 2); gridLayout->addWidget(new QLabel(tr("Saturation")), 1, 1, Qt::AlignRight); gridLayout->addWidget(satSpinBox, 1, 2); gridLayout->addWidget(new QLabel(tr("Value")), 2, 1, Qt::AlignRight); gridLayout->addWidget(valSpinBox, 2, 2); gridLayout->addWidget(new QLabel(tr("Red")), 0, 3, Qt::AlignRight); gridLayout->addWidget(redSpinBox, 0, 4); gridLayout->addWidget(new QLabel(tr("Blue")), 2, 3, Qt::AlignRight); gridLayout->addWidget(blueSpinBox, 2, 4); gridLayout->addWidget(new QLabel(tr("Green")), 1, 3, Qt::AlignRight); gridLayout->addWidget(greenSpinBox, 1, 4); gridLayout->addWidget(new QLabel(tr("Hex")), 3, 1, Qt::AlignRight); gridLayout->addWidget(hexLineEdit, 3, 2, 1, 4); mainLayout->addLayout(hBoxLayout); mainLayout->addLayout(gridLayout); mainLayout->addWidget(dialogButtonBox); setLayout(mainLayout); }
-
Hi,
On which layout did you apply your custom constraints ?
-
You did not add any spacer items so everything is stretched so it's using the whole size of the dialog.
I would suggest using the designer for this so you can play around with the different contraints and spacers more easily. -
@Christian-Ehrlicher Awesome, spacers did the trick! Thanks a lot!
-