开发者

How to catch the QSystemTrayIcon quit event?

开发者 https://www.devze.com 2023-03-25 09:29 出处:网络
I ha开发者_JS百科ve a QSystemTrayIcon subclass. Inside it, I have: quitAction = new QAction(tr(\"&Quit\"), m_parent);

I ha开发者_JS百科ve 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消