我想在操作开始时禁用窗口(主应用程序窗口)上的关闭按钮,这样用户无法退出应用程序并在操作完成时再次启用它.我怎么能在Qt应用程序中这样做?我的平台是Windows 7.
或者,如果用户按下关闭按钮并退出应用程序进程正在后台运行并中止关闭应用程序,我可以显示一条消息.
我该怎么办?
如果你想要禁用按钮,你可以使用下一个:
auto flags = windowFlags();//save current configuration
//your main configuration which do the trick
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint );
//...
setWindowFlags(flags);//restore
Run Code Online (Sandbox Code Playgroud)
如果您确定此类"功能"不会激怒您的用户,您可以使用此功能,在另一种情况下,请使用评论中的链接.