pyQt5 change MainWindow Flags
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.
PyQt window flags
PyQt has these window flags:
PyQt has these window flags:
- Qt.MSWindowsFixedSizeDialogHint
- Qt.X11BypassWindowManagerHint
- Qt.FramelessWindowHint
- Qt.WindowTitleHint
- Qt.WindowSystemMenuHint
- Qt.WindowMinimizeButtonHint
- Qt.WindowMaximizeButtonHint
- Qt.WindowCloseButtonHint
- Qt.WindowContextHelpButtonHint
- Qt.WindowShadeButtonHint
- Qt.WindowStaysOnTopHint
- Qt.WindowStaysOnBottomHint
- Qt.CustomizeWindowHint
沒有留言:
張貼留言