用户手动关闭系统时的事件处理程序
当关闭消息发送到系统时,我需要一个事件处理程序。 有人可以帮忙吗?
当我们尝试关闭系统时,如果有任何对话框打开,关闭进程就会终止。我不希望这种情况发生在我的应用程序中。即,如果从我的应用程序打开任何对话框并且我尝试关闭我的系统,那么它不应该阻止关闭过程。这个实现可能吗?
谢谢, 拉胡尔
I need a event handler when ever shutdown message is send to system.
Can anyone help?
When ever we try to shutdown a system, and if any dialog box is open shutdown process terminates. I don't want this to happen in my application. i.e if any dialog box is open from my application and I try to shutdown my system then it should not block shutdown process. Is this implementation possible?
Thanks,
Rahul
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,看看 NSWorkspaceWillPowerOffNotification
http ://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSWorkspace_Class/Reference/Reference.html
Yes, look at NSWorkspaceWillPowerOffNotification
http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSWorkspace_Class/Reference/Reference.html
尝试覆盖 QApplication::commitData 当用户关闭系统时应该调用它并且您的应用程序仍在运行。
下面是一个示例(从未在 Mac 上尝试过;尽管在我的 ubuntu 上运行良好):
main.cpp:
希望这会有所帮助,问候
try overriding QApplication::commitData it should be called whenever user shuts down the system and your application is still running.
below is an example (never tried it with macs; though works fine on my ubuntu):
main.cpp:
hope this helps, regards