无法隐藏或禁用 QWizard 上的关闭按钮 [英] Can't hide or disable the close button on QWizard

查看:106
本文介绍了无法隐藏或禁用 QWizard 上的关闭按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,QWizard 对话框在右上角有一个上下文帮助 [?] 和一个关闭 [X] 按钮.我可以隐藏上下文帮助按钮,但我无法使用 setWindowFlags 使关闭按钮消失.例如:

A QWizard dialog by default has a context help [?] and a close [X] button in the top right corner. I can hide the context help button, but I can't get the close button to disappear using setWindowFlags. For example:

# preserves current window flags but removes context help button
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)

# has no effect
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint)

有人知道这是为什么吗?

Anyone know why this is?

推荐答案

CustomizeWindowHint 标记需要先设置,然后 WindowCloseButtonHint 标记才能更改.完整代码为:

The CustomizeWindowHint flag needs to be set before the WindowCloseButtonHint flag can be changed. The full code is:

# enable custom window hint
self.setWindowFlags(self.windowFlags() | QtCore.Qt.CustomizeWindowHint)

# disable (but not hide) close button
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint)

这篇关于无法隐藏或禁用 QWizard 上的关闭按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆