<div dir="ltr"><div style="font-family:tahoma,sans-serif" class="gmail_default"></div><div class="gmail_default" style="font-family:tahoma,sans-serif">I am having trouble getting a method returning "flags" to return 0/zero/no flags.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Specifically, I am translating a Qt example (<a rel="nofollow" href="https://doc.qt.io/qt-5/qtwidgets-layouts-flowlayout-example.html">https://doc.qt.io/qt-5/qtwidgets-layouts-flowlayout-example.html</a>, <a rel="nofollow" href="https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/layouts/flowlayout">https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/layouts/flowlayout</a>), from C++ to PyQt. It overrides <span style="font-family:courier new,monospace">QLayout::expandingDirections()</span> as follows:<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="margin-left:40px"><pre class="gmail-cpp gmail-prettyprint gmail-prettyprinted"><span style="font-family:courier new,monospace"><span class="gmail-type"><a href="https://doc.qt.io/qt-5/qt.html"><span class="gmail-typ">Qt</span></a></span><span class="gmail-operator"><span class="gmail-pun">::</span></span><span class="gmail-typ">Orientations</span><span class="gmail-pln"> </span><span class="gmail-typ">FlowLayout</span><span class="gmail-operator"><span class="gmail-pun">::</span></span><span class="gmail-pln">expandingDirections</span><span class="gmail-pun">()</span><span class="gmail-pln"> </span><span class="gmail-keyword"><span class="gmail-kwd">const</span></span><span class="gmail-pln">
</span><span class="gmail-pun">{</span><span class="gmail-pln">
</span><span class="gmail-keyword"><span class="gmail-kwd">return</span></span><span class="gmail-pln"> </span><span class="gmail-number"><span class="gmail-lit">0</span></span><span class="gmail-pun">;</span><span class="gmail-pln">
</span><span class="gmail-pun">}</span></span></pre></div><div class="gmail_default" style="font-family:tahoma,sans-serif"></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><span style="font-family:courier new,monospace">Qt::Orientations</span> is a "flags", with the two defined enumeration values being 1 & 2.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Basically if I define my Python override to <span style="font-family:courier new,monospace">return 0</span> I get runtime error:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><p style="margin:0px 0px 0px 40px;text-indent:0px;white-space:pre-wrap"><span style="font-family:courier new,monospace">invalid result from JFlowLayout.expandingDirections(), int cannot be converted to PyQt5.QtCore.Orientations in this context</span></p><div style="margin-left:40px"><span style="font-family:courier new,monospace">
</span></div><p style="margin:0px 0px 0px 40px;text-indent:0px;white-space:pre-wrap"><span style="font-family:courier new,monospace"></span></p><div style="margin-left:40px"><span style="font-family:courier new,monospace">
</span></div><p style="margin:0px 0px 0px 40px;text-indent:0px;white-space:pre-wrap"><span style="font-family:courier new,monospace"><class 'TypeError'></span></p></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">If I <span style="font-family:courier new,monospace">return QOrientations()</span> that works, but I'm unsure if that guarantees to return zero.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">If I <span style="font-family:courier new,monospace">return QOrientations(0)</span> that too works, but my PyCharm IDE marks the source with an "Unexpected type 'int'" for the parameter.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Which is the "correct"/"best" way to return a "flags" like this from Python/PyQt, please?<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br clear="all"></div><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><span style="font-family:tahoma,sans-serif">Kindest,</span></div><div><span style="font-family:tahoma,sans-serif">Jonathan</span></div></div></div></div></div></div>