PDA

View Full Version : What is the right way of deleting widgets ?



tonnot
13th February 2012, 07:33
I have a custom widget. Inside it I create some other widgets, without tellingt them the parent.
When the main widget is closed, whats happen with them ? Are they auto-deleted or destroyed ? If they are not destroyed, have I memory leaks?
Thanks.

FelixB
13th February 2012, 08:19
are these widgets arranged within a layout? in that case, they get reparented automatically which means they get destroyed when the layout gets destroyed. If you do't have a layout, they will not be destroyed - c++ does not have any garbage collector like java. And yes, then you have memory leaks (assuming you create the widgets with "new" and don't use smart pointers to store them).

hth,
Felix