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

J Barchan jnbarchan at gmail.com
Thu Jul 11 14:33:11 BST 2019


On Thu, 11 Jul 2019 at 07:56, J Barchan <jnbarchan at gmail.com> wrote:

>
>
> On Wed, 10 Jul 2019 at 21:28, Barry Scott <barry at barrys-emacs.org> wrote:
>
>>
>>
>> On 10 Jul 2019, at 11:55, J Barchan <jnbarchan at gmail.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190711/0b5ad860/attachment.html>


More information about the PyQt mailing list