我有一个QSystemTrayIcon
子类。在里面,我有:
quitAction = new QAction(tr("&Quit"), m_parent);
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
CloseEvent 在这里不起作用。我怎样才能捕获这个退出事件?我想在关闭之前保存数据。
最佳答案
您应该将清理/保存代码连接到 QCoreApplication::aboutToQuit()信号。
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.
关于c++ - 如何捕获 QSystemTrayIcon 退出事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6889368/