[Interest] Triggering Actions on Application Close

Mitchell Verter mitchell.verter at gmail.com
Tue Jul 9 00:33:44 CEST 2013


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)

and also

connect(&myMainWindow, SIGNAL(destroy()), &myMainWindow,
SLOT(closeFileSlot()));

Neither of these approaches seems to successfully trigger the closeFileSlot()
Any suggestions about what the right technique might be?

Thanks
Mitchell



More information about the Interest mailing list