Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't hide or disable the close button on QWizard

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?

like image 512
101 Avatar asked Dec 16 '14 02:12

101


1 Answers

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)
like image 74
101 Avatar answered Nov 03 '22 18:11

101