[Qt-interest] QObject destructor

Nikos Chantziaras realnc at arcor.de
Tue May 4 21:50:16 CEST 2010


On 05/04/2010 10:43 PM, Yifei Li wrote:
> Hi folks,
>
> I'm wondering if  QObject destructor will delete the object's
> children.
>
> For example, I have my own class MyWidget,  and in its constructor
> widgets are created on the stack  with parent being the MyWidget
> object. So do I need to delete all the widgets created on the stack
> in MyWidget's destructor?

Don't create widgets on the stack if they have a parent.  Never. 
~QObject() will try to delete them, and since they're on the stack, this 
will bomb at some point.



More information about the Qt-interest-old mailing list