Reputation: 724
I have a pointer of QWidget subclass:
QWidget * form;
Next I put the instance of the subclass as an internal widget of QMdiSubWindow:
QMdiSubWindow * w = mdiArea->addSubWindow(form);
How to make sure that the object form
is deleted when the MDI subwindow w
is closed?
Upvotes: 0
Views: 896
Reputation: 13708
According to the documentation you must set the Qt::WA_DeleteOnClose
flag on the subwindow so it will be automatically deleted after it is closed.
Back to your actual question: when you call addSubWindow
it calls setWidget
internally. After that step the passed widget's parent is the QMdiSubWindow
object on which the call was made. Hence, after that object gets deleted it will also delete all its children, including the said widget, as [almost] any dutiful Qt object does.
Upvotes: 2