[Qt-interest] Nested widget disappears when I add a spacer item / dynamically adding widgets to widgets
Kustaa Nyholm
Kustaa.Nyholm at planmeca.com
Wed May 26 11:13:29 CEST 2010
Related to my unanswered question yesterday here is a more specific
test case:
I've got following simple code:
gLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
QWidget* top=new QWidget();
new QPushButton("A",top);
gLayout->addWidget(top);
gLayout->addWidget(new QPushButton("B"));
This works, and displays two buttons, A and B.
But if I add a spacer to the mix by adding a single line:
gLayout->addItem(
new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
then button A disappers!
What is going on?
Note that button A is a child of the widget 'top' which is what I add
to the layout. If I add A button to gLayout directly then there is no
problem but inmy bigger application that is not feasible because 'top' is a
form maintained with Qt Designer...
So what is the proper way to add a widget that contains widgets
to a layout?
br Kusti
More information about the Qt-interest-old
mailing list