gpt4 book ai didi

c++ - 如何捕捉 QSystemTrayIcon 退出事件?

转载 作者:搜寻专家 更新时间:2023-10-31 01:56:34 25 4
gpt4 key购买 nike

我有一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com