[PyQt] Qt/PyQt 5.9.x. Correct way to get an "enumeration flags" to return 0?
J Barchan
jnbarchan at gmail.com
Wed Jul 10 11:55:48 BST 2019
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190710/bdf793d5/attachment.html>
More information about the PyQt
mailing list