Qt/PyQt 5.9.x. Correct way to get an "enumeration flags" to return 0?

J Barchan <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <CABz3M_8ne2pAJisgzSg6Wb3oYk9N-aK9mWuUAOwHkOcQV7SScw@mail.gmail.com>
I am having trouble getting a method returning "flags" to return 0/zero/no
flags.

Specifically, I am translating a Qt example (
https://doc.qt.io/qt-5/qtwidgets-layouts-flowlayout-example.html,
https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/layouts/flowlayout),
from C++ to PyQt.  It overrides QLayout::expandingDirections() as follows:

Qt <https://doc.qt.io/qt-5/qt.html>::Orientations
FlowLayout::expandingDirections() const{
    return 0;}

Qt::Orientations is a "flags", with the two defined enumeration values
being 1 & 2.

Basically if I define my Python override to return 0 I get runtime error:

invalid result from JFlowLayout.expandingDirections(), int cannot be
converted to PyQt5.QtCore.Orientations in this context

<class 'TypeError'>

If I return QOrientations() that works, but I'm unsure if that guarantees
to return zero.

If I return QOrientations(0) that too works, but my PyCharm IDE marks the
source with an "Unexpected type 'int'" for the parameter.

Which is the "correct"/"best" way to return a "flags" like this from
Python/PyQt, please?



-- 
Kindest,
Jonathan

_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.