PDA

View Full Version : delete sub windows when they are closed?



Dark_Tower
21st March 2006, 17:19
Hi all, I've got a dialog window that can open one or more sub windows. These sub windows are subclasses of QMainWindow. My question is if it's convenient to delete the main windows everytime they are closed or let the application to delete them when the dialog (the parent of the main windows) is closed.

Thanks.

jacek
21st March 2006, 17:33
Just set the Qt::WA_DeleteOnClose attribute.

Dark_Tower
21st March 2006, 17:44
Thanks a lot jacek. I also want to do 2 more questions in adition with the previous:
1) If I make a connection in the dialog window with a signal from the main window, it's convenient/necesary to disconnect it when the user closes the main window?

2) I want to know the moment when each window is closed, because the dialog window has to do some updates. Is it a simpler way to know when a sub window is closed than emiting a signal in the closeEvent of the main window?

jacek
21st March 2006, 18:50
If I make a connection in the dialog window with a signal from the main window, it's convenient/necesary to disconnect it when the user closes the main window?
It depends, you probably don't want to disconnect the signal that is connected to QWidget::show(). When QObject is destroying itself, it disconnects all signals.


Is it a simpler way to know when a sub window is closed than emiting a signal in the closeEvent of the main window?
IMO the safest way is adding emit in closeEvent.