pyQt5 change MainWindow Flags
I would propose a different solution, because it keeps the existing flags. Reason to do this, is to NOT mingle with UI-specific presets (like that a dialog has not by default a "maximize" or "minimize" button).
self.setWindowFlags(self.windowFlags() # reuse initial flags
& ~QtCore.Qt.WindowContextHelpButtonHint # negate the flag you want to unset
)
Every call of setWindowFlags
will completely override the current settings, so you need to set all the flags at once. Also, you must include the CustomizeWindowHint
flag, otherwise all the other hints will be ignored. The following will probably work on Windows:
self.setWindowFlags(
QtCore.Qt.Window |
QtCore.Qt.CustomizeWindowHint |
QtCore.Qt.WindowTitleHint |
QtCore.Qt.WindowCloseButtonHint |
QtCore.Qt.WindowStaysOnTopHint
)
However, it is highly unlikely this will work on all platforms. "Hint" really does mean just that. Window managers are completely free to ignore these flags and there's no guarantee they will all behave in the same way.
PS:
It is not possible to set the window flags in Qt Designer.