How to test if WindowStaysOnTopHint flag is set in windowFlags?
<p>Is this supposed to return a boolean value?</p>

<pre><code>&gt;&gt;&gt; win.windowFlags() &amp; QtCore.Qt.WindowStaysOnTopHint
&lt;PyQt4.QtCore.WindowFlags object at 0x7ad0578&gt;
</code></pre>

<p>I already knew that</p>

<pre><code># enable always on top
win.windowFlags() | QtCore.Qt.WindowStaysOnTopHint

# disable it
win.windowFlags() &amp; ~QtCore.Qt.WindowStaysOnTopHint

# toggle it 
win.windowFlags() ^ QtCore.Qt.WindowStaysOnTopHint
</code></pre>

<p>The <code>WindowFlags</code> object is an OR'd together set of flags from the <code>WindowType</code> enum. The <code>WindowType</code> is just a subclass of <code>int</code>, and the <code>WindowFlags</code> object also supports <code>int</code> operations.</p>

<p>You can test for the presence of a flag like this:</p>

<pre><code>&gt;&gt;&gt; bool(win.windowFlags() &amp; QtCore.Qt.WindowStaysOnTopHint)
False
</code></pre>

<p>or like this:</p>

<pre><code>&gt;&gt;&gt; int(win.windowFlags() &amp; QtCore.Qt.WindowStaysOnTopHint) != 0
False
</code></pre>

<p>In general, <code>&amp;</code> returns the value itself when present, or zero when absent:</p>

<pre><code>&gt;&gt;&gt; flags = 1 | 2 | 4
&gt;&gt;&gt; flags
7
&gt;&gt;&gt; flags &amp; 2
2
&gt;&gt;&gt; flags &amp; 8
0
</code></pre>

python pyqt bit-manipulation flags always-on-top