
Originally Posted by
conexion2000
Here is sample:
So I would like to do something similar. As You can see there is some QGroupBox with 3 horizontal QLayouts in it. These layouts contains some widgets. And here appears my problem. How to put these layouts inside this groupbox. Setting QGroupBox as a parent doesn't seem to work, because debug functions say that QGroupBox already have a layout. When I do that in a "traditional way" (creating QLayout with QGroupBox as a parent) these widgets don't show in program.
Please help.
You must use QWidget::setLayout.
lay1->addWidget(wgt1_1);
...
lay1->addWidget(wgt1_N);
..........
layN->addWidget(wgtN_1);
...
layN->addWidget(wgtN_N);
v->addLayout(lay1);
...
v->addLayout(layN);
grpBox->setLayout(v)
QHBoxLayout* lay1 = new QHBoxLayout;
lay1->addWidget(wgt1_1);
...
lay1->addWidget(wgt1_N);
..........
QHBoxLayout* layN = new QHBoxLayout;
layN->addWidget(wgtN_1);
...
layN->addWidget(wgtN_N);
QVBoxLayout* v = new QVBoxLayout;
v->addLayout(lay1);
...
v->addLayout(layN);
grpBox->setLayout(v)
To copy to clipboard, switch view to plain text mode
where wgtX_X are widget to add and grpBox are your QGroupBox.
Bookmarks