Can't hide or disable the close button on QWizard

不想你离开。 提交于 2020-01-13 10:23:09

问题


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?


回答1:


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)


来源:https://stackoverflow.com/questions/27496686/cant-hide-or-disable-the-close-button-on-qwizard

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!