Re: 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_8O9at=ADv5W-6Us9cNnV-B4xhu6EvTt3Xq-vX0t1ZMdQ@mail.gmail.com> |
On Thu, 11 Jul 2019 at 07:56, J Barchan <[email protected]> wrote: > > > On Wed, 10 Jul 2019 at 21:28, Barry Scott <[email protected]> wrote: > >> >> >> On 10 Jul 2019, at 11:55, J Barchan <[email protected]> wrote: >> >> If I return QOrientations() that works, but I'm unsure if that >> guarantees to return zero. >> >> >> I've not tried this - not ready to update Qt yet - does this print 0 to >> confirm the value in the enum? >> >> print( int( QOrientations()) >> >> Barry >> >> > I confirm that int( QOrientations() ) returns 0. Assuming that is > consistent/deliberate and not random (which I imagine it is) I guess that > is what I will use here. > > I am still a little troubled by the fact that I can convert enum to int > via int(QOrientations(enum_value)) but have trouble converting int to > enum via QOrientations(int_value). However the latter does seem to be a > PyCharm IDE warning ("Unexpected type 'int', expected 'Orientations', > 'Orientation'") but works at run-time, so I guess it's OK even if I > cannot find a formula which works without warning. It would be nice to see > a PyQt expert statement on what is the correct way to handle this > not-unusual requirement.... > > > > -- > Kindest, > Jonathan > Ah ha, I think I've got it! Qt.Orientations(0) generates a warning in my IDE, but Qt.Orientations(Qt.Orientation(0)) seems not to! :) Fair enough.... -- Kindest, Jonathan _______________________________________________ PyQt mailing list [email protected] https://www.riverbankcomputing.com/mailman/listinfo/pyqt