Reputation: 30885
I have a QSystemTrayIcon
subclass. Inside it, I have:
quitAction = new QAction(tr("&Quit"), m_parent);
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
CloseEvent doesn't work here. How can I catch this quit event? I want to save data before closing.
Upvotes: 2
Views: 350
Reputation: 206679
You should connect your cleanup/save code to the QCoreApplication::aboutToQuit() signal.
This signal is emitted when the application is about to quit the main event loop, e.g. when the event loop level drops to zero. This may happen either after a call to quit() from inside the application or when the users shuts down the entire desktop session.
Upvotes: 3