PDA

View Full Version : Close event



gyre
20th November 2007, 01:32
Hi...got a little question...
when I create widget this way:
OpenHistoryView *sentMsgHistoryView = new OpenHistoryView(this);
and "this" is a MainWindow (main application)...why isnt the widget deleted when I close the MainWindow that is actually a parent of it ?? or it just doesnt behave as I supposed it should ?
By deleted I mean Destroyed/Closed with the mainwindow....I dont understand why not :(
anyone ideas ?
THANKS :)

wysota
20th November 2007, 07:01
Closing a widget doesn't make Qt delete it by default. You have to either call delete or deleteLater on it explicitely or set the Qt::WA_DeleteOnClose attribute on the widget.

gyre
20th November 2007, 11:22
Im not closing the widget....
Im closing THE MAINWINDOW that is a parent of that widget and I want that WIDGET to be closed with the mainwindow SINCE the mainwindow is a parent of that widget...
As I understand that....When I close the parent it should get deleted and all children should get to...

wysota
20th November 2007, 13:49
Im not closing the widget....
Im closing THE MAINWINDOW that is a parent of that widget and I want that WIDGET to be closed with the mainwindow SINCE the mainwindow is a parent of that widget...

You mean that the window is closed but one of its children remains visible? Somehow I can't even imagine that... Could you post a screenshot?


As I understand that....When I close the parent it should get deleted and all children should get to...
No, read my post again - Qt doesn't delete widgets (top level ones, like your main window, included) if you don't ask it to, either by deleting them, deleting their parents or setting the DeleteOnClose attribute on the top level window (or probably any widget).