[Interest] Triggering Actions on Application Close

Syam Krishnan syamcr at gmail.com
Tue Jul 9 03:11:35 CEST 2013


On 07/09/2013 04:03 AM, Mitchell Verter wrote:
> How do I trigger cleanup actions on application close?
>
> I need to write out temporary objects and a footer to a file whenever
> the Application is closed.
>
> I've tried several approaches, but none of them produces any result
> when I "Force Quit" by hitting the red button within QtCreator.
>
> More specifically, I have tried to connect:
>
>      QObject::connect(&myApplication, SIGNAL(aboutToQuit()),
> &myMainWindow,  SLOT(closeFileSlot()));
>
> (note that I am using a QApplication rather than a QCoreApplication --
> I'm not sure if it makes a difference)


You could try the signal QApplication::lastWindowClosed() or override 
the closeEvent() function of your QMainWindow class.

regards,

Syam



More information about the Interest mailing list