PDA

View Full Version : adding a QCheckBox to a QLayout makes QWidget not display -- no matter how its added



planetLars
17th April 2010, 23:34
Hello,

I'm adding a QCheckBox to a QLayout. The QWidget in which the QLayout resides is not being displayed under Windows 7. It is shown in the taskbar and I can maximize it from there thus making it display but it is not displayed as a regular window. No matter what I tried to get the QCheckBox into the QLayout.
Here's the code:

private:
QSize size;
QBoxLayout* boxLayout;
QFormLayout* formLayout;
QLabel* label;
QDoubleSpinBox* doubleSpinBox;
QLabel* label_2;
QDoubleSpinBox* doubleSpinBox_2;
QLabel* label_3;
QDoubleSpinBox* doubleSpinBox_3;
QLabel* label_4;
QDoubleSpinBox* doubleSpinBox_4;
QLabel* label_5;
QCheckBox* checkBox;
Declared inside X.h

X::X() : size(202,157)
{
boxLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
formLayout = new QFormLayout();
label = new QLabel("a");
doubleSpinBox = new QDoubleSpinBox(this);
doubleSpinBox->setDecimals(3);
doubleSpinBox->setMaximum(1);
doubleSpinBox->setSingleStep(0.001);
formLayout->addRow(label, doubleSpinBox);
label_2 = new QLabel("a");
doubleSpinBox_2 = new QDoubleSpinBox();
doubleSpinBox_2->setDecimals(3);
doubleSpinBox_2->setMaximum(1);
doubleSpinBox_2->setSingleStep(0.001);
formLayout->addRow(label_2, doubleSpinBox_2);
label_3 = new QLabel("a");
doubleSpinBox_3 = new QDoubleSpinBox();
doubleSpinBox_3->setDecimals(3);
doubleSpinBox_3->setMaximum(1);
doubleSpinBox_3->setSingleStep(0.001);
formLayout->addRow(label_3, doubleSpinBox_3);
label_4 = new QLabel("a");
doubleSpinBox_4 = new QDoubleSpinBox();
doubleSpinBox_4->setDecimals(3);
doubleSpinBox_4->setMaximum(1);
doubleSpinBox_4->setSingleStep(0.001);
formLayout->addRow(label_4, doubleSpinBox_4);
boxLayout->addLayout(formLayout);
checkBox = new QCheckBox("a");
//boxLayout->addWidget(checkBox); // enabling this line makes the QWidget X not display
}

I tried adding a label and the QCheckBox to the QFormLayout and didn't have the QBoxLayout but it didn't work. I thought it's perhaps the QFormLayout only accepting "input QWidgets" and QCheckBox isn't defined as an "input QWidget" according to QDesigner, thus I switched to a QBoxLayout containing a QFormLayout and a QCheckBox to no avail.

:confused: Help!

Lars

planetLars
19th April 2010, 12:27
error lies at different part, see http://www.qtcentre.org/threads/29961-BUG-adding-5-child-widgets-to-a-widgets-layout-makes-widget-invisible