PDA

View Full Version : removing child widget



db
16th August 2007, 12:15
OK. I have created a widget that in turn creates child widgets. They are created when the main widget is instantiated. Question is: How do I remove the child widgets when the main widget is closed?

I thought that the following code would make the child wodget dependant there by removing it when the main was exited.


MainClass::MainClass(QWidget *parent){
...

ChildClass chwidget = new ChildClass(this);

....
}

jpn
16th August 2007, 12:19
A widget is not deleted by the time it's closed. You can change this behaviour by setting Qt::WA_DeleteOnClose (http://doc.trolltech.com/4.3/qwidget.html#setAttribute) attribute.