【问题标题】:How to disable the close button of window using Qt?如何使用 Qt 禁用窗口的关闭按钮?
【发布时间】:2015-10-12 19:01:48
【问题描述】:

我想在操作开始时禁用窗口(主应用程序窗口)上的关闭按钮,以便用户无法退出应用程序并在操作完成后再次启用它。我怎样才能在 Qt 应用程序中做到这一点?我的平台是 Windows 7。

或者,如果用户按下关闭按钮并退出应用程序,表明进程正在后台运行并中止关闭应用程序,我可以显示一条消息。

我该怎么做?

【问题讨论】:

标签: qt


【解决方案1】:

如果你想禁用按钮,你可以使用下一步:

auto flags = windowFlags();//save current configuration
//your main configuration which do the trick
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint );
//...
setWindowFlags(flags);//restore

如果您确定此类“功能”不会激怒您的用户,您可以使用此功能,在另一种情况下使用评论中的链接。

【讨论】:

  • 谢谢,但这会导致应用程序过早退出。 MyApp.exe exited with code 0 当它被调用时。
猜你喜欢
  • 2012-05-09
  • 1970-01-01
  • 2010-11-06
  • 1970-01-01
  • 2015-05-29
  • 2018-05-02
  • 2022-01-22
  • 2013-04-08
相关资源
最近更新 更多