user63898
user63898

Reputation: 30885

How to catch the QSystemTrayIcon quit event?

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

Answers (1)

Mat
Mat

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

Related Questions