
Originally Posted by
Jason Hamilton
I tried using connect on the mainWindow object and it doesn't appear to work, given that QMainWindow doesn't appear to inherit the aboutToClose SIGNAL from QApplication.
If you want to connect anything to aboutToClose() signal, use QCoreApplication::instance() as the source of the signal.

Originally Posted by
Jason Hamilton
My initial thought was to use the connect function in main, but I can't get it to call the function because the SLOT isn't defined.
I think that the error message was rather about connect(), which is a static method of QObject class, so in main you use it this way:
QObject::connect( ...,
SIGNAL( ...
), ...,
SLOT( ...
) );
QObject::connect( ..., SIGNAL( ... ), ..., SLOT( ... ) );
To copy to clipboard, switch view to plain text mode

Originally Posted by
Jason Hamilton
Should I derive a class from QApplication?
It's one way of doing this. Another one is to create QObject subclass that will handle the clean-up process. Remember that the GUI might not exist at the time aboutToClose() is emitted.
Also take a look at qAddPostRoutine().
Bookmarks