Is this supposed to return a boolean value?
>>> win.windowFlags() & QtCore.Qt.WindowStaysOnTopHint
<PyQt4.QtCore.WindowFlags object at 0x7ad0578>
I already knew that
# enable always on top
win.windowFlags() | QtCore.Qt.WindowStaysOnTopHint
# disable it
win.windowFlags() & ~QtCore.Qt.WindowStaysOnTopHint
# toggle it
win.windowFlags() ^ QtCore.Qt.WindowStaysOnTopHint
The WindowFlags
object is an OR'd together set of flags from the WindowType
enum. The WindowType
is just a subclass of int
, and the WindowFlags
object also supports int
operations.
You can test for the presence of a flag like this:
>>> bool(win.windowFlags() & QtCore.Qt.WindowStaysOnTopHint)
False
or like this:
>>> int(win.windowFlags() & QtCore.Qt.WindowStaysOnTopHint) != 0
False
In general, &
returns the value itself when present, or zero when absent:
>>> flags = 1 | 2 | 4
>>> flags
7
>>> flags & 2
2
>>> flags & 8
0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With