Does Qt destroy the widgets automatically or do I need to destroy them myself?
Hi!
I am very confused about what a parent means in Qt. I looked at Qt's homepage, I'm especially confused about destruction of widgets. Does parenting have something to do with it?
If I have a widget A and creates a widget B which I set as a child to A, what does this mean besides layout matters? Does it mean that B's destructor is called automatically by Qt when A is destroyed? Does Qt handle all destruction of the GUI? If I create a window with no parent, is this not destroyed by Qt?
Where can I read about this?
It would be nice if someone could tell me where I can read about destruction, since I have a lot of questions and it maybe is best if I can read about it.
pir
Re: Does Qt destroy the widgets automatically or do I need to destroy them myself?
Quote:
Originally Posted by pir
Does it mean that B's destructor is called automatically by Qt when A is destroyed?
When QObject is being destroyed, it destroys all of its children.
Since every QWidget is a QObject, all widgets destroy their children automatically.
Quote:
Originally Posted by pir
Does Qt handle all destruction of the GUI? If I create a window with no parent, is this not destroyed by Qt?
No, you have to destroy all widgets without parents yourself (unless you have set the Qt::WA_DeleteOnClose attribute).
http://doc.trolltech.com/4.1/objecttrees.html