PDA

View Full Version : Method to close the application and go through the close event!?



hakermania
17th December 2010, 14:54
I want to use qApp->exit(0) or qApp->quit() in order to close my application while being in a QDialog (e.g. a button in a dialog saying "Exit").
qApp->exit and qApp->quit do the job but, as I noticed they don't go through the QClose Event. Is there a way to go through the QClose Event of the main application and not through the dialog's Close Event?

franz
17th December 2010, 19:55
Since QApplication is not a QWidget, it is not strange that it doesn't have a closeEvent(). Maybe it would be an idea for you to connect to the QCoreApplication::aboutToQuit() (http://doc.trolltech.com/latest/qcoreapplication.html#aboutToQuit) signal.

nroberts
17th December 2010, 20:01
I just tell the main window to close(). It's sufficient in my case, may not be in yours if you have more than one.