<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 11 Jul 2019 at 15:10, Phil Thompson <<a href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 11/07/2019 07:56, J Barchan wrote:<br>
> On Wed, 10 Jul 2019 at 21:28, Barry Scott <<a href="mailto:barry@barrys-emacs.org" target="_blank">barry@barrys-emacs.org</a>> <br>
> wrote:<br>
> <br>
>> <br>
>> <br>
>> On 10 Jul 2019, at 11:55, J Barchan <<a href="mailto:jnbarchan@gmail.com" target="_blank">jnbarchan@gmail.com</a>> wrote:<br>
>> <br>
>> If I return QOrientations() that works, but I'm unsure if that <br>
>> guarantees<br>
>> to return zero.<br>
>> <br>
>> <br>
>> I've not tried this - not ready to update Qt yet - does this print 0 <br>
>> to<br>
>> confirm the value in the enum?<br>
>> <br>
>> print( int( QOrientations())<br>
>> <br>
>> Barry<br>
>> <br>
>> <br>
> I confirm that int( QOrientations() ) returns 0.  Assuming that is<br>
> consistent/deliberate and not random (which I imagine it is) I guess <br>
> that<br>
> is what I will use here.<br>
> <br>
> I am still a little troubled by the fact that I can convert enum to int <br>
> via<br>
> int(QOrientations(enum_value)) but have trouble converting int to enum <br>
> via<br>
> QOrientations(int_value).  However the latter does seem to be a PyCharm <br>
> IDE<br>
> warning ("Unexpected type 'int', expected 'Orientations', <br>
> 'Orientation'")<br>
> but works at run-time, so I guess it's OK even if I cannot find a <br>
> formula<br>
> which works without warning.  It would be nice to see a PyQt expert<br>
> statement on what is the correct way to handle this not-unusual<br>
> requirement....<br>
<br>
As you say the warning is coming from your IDE and I have no idea what <br>
introspection it is doing to determine exactly what types are allowed. <br>
As Orientation is an enum then an int is also allowed.<br>
<br>
Phil<br>
</blockquote></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Hi Phil,</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">You wrote:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span style="font-family:Arial,Helvetica,sans-serif">As Orientation is an enum then an int is also allowed.</span> </blockquote><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style=""><span style="font-family:tahoma,sans-serif"> Yes, </span><font face="courier new, monospace">Orientation</font><span style="font-family:tahoma,sans-serif"> is an enum, so </span><font face="courier new, monospace">Orientation(0)</font><font face="tahoma, sans-serif"> is an acceptable construct for that.  But the function returns an </font><font face="courier new, monospace">Orientations</font><font face="tahoma, sans-serif">, not an </font><font face="courier new, monospace">Orientation</font><font face="tahoma, sans-serif">.  Note the spelling (the extra "s" on the end), it's vital.  </font><font face="courier new, monospace">Orientations</font><font face="tahoma, sans-serif"> is a <i>flags</i>, not an <i>enum</i>.  The IDE accepts </font><font face="courier new, monospace">Orientation(0)</font><font face="tahoma, sans-serif"> (an enum) but not </font><font face="courier new, monospace">Orientations(0)</font><font face="tahoma, sans-serif"> (a flags).  For </font><font face="courier new, monospace">Orientations</font><font face="tahoma, sans-serif"> it only accepts one or more </font><font face="courier new, monospace">Orientation</font><font face="tahoma, sans-serif"> joined together.</font><br></div><div class="gmail_default" style=""><font face="tahoma, sans-serif"><br></font></div><div class="gmail_default" style=""><font face="tahoma, sans-serif">That is why in my latest post a while ago, which you don't seem to be replying to, I said I seemed to have cracked it: </font><font face="courier new, monospace">Orientations(0)</font><font face="tahoma, sans-serif"> offends the IDE, but </font><font face="courier new, monospace">Orientations(Orientation(0))</font><font face="tahoma, sans-serif"> works good!</font></div><div class="gmail_default" style=""><font face="tahoma, sans-serif"><br></font></div>-- <br><div dir="ltr" class="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>