tags:

views:

257

answers:

1

I'm trying to put a new customized widget when the user press a button, using layout->addWidget(mywidget) where layout is a QVBoxLayout, but it's not working.

Tried: - Passing this to the widget constructor as parent - Passing the layout pointer as the parent - Passing 0 as the parent - The scrollArea pointer where the customized widget should be in as the parent

None works. When layout->addWidget is called in the constructor it works though.

+1  A: 

Nevermind, just use widget->show() and everything goes fine. Weird, qt should do this by default, no?

Humberto Pinheiro
No. By the way such behavior is documented http://qt.nokia.com/doc/4.6/qwidget.html#QWidget"If you add a child widget to an already visible widget you must explicitly show the child to make it visible."
kemiisto