<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 3 May 2018 at 18:01, Phil Thompson <span dir="ltr"><<a href="mailto:phil@riverbankcomputing.com" target="_blank">phil@riverbankcomputing.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 3 May 2018, at 5:32 pm, J Barchan <<a href="mailto:jnbarchan@gmail.com">jnbarchan@gmail.com</a>> wrote:<br>
> <br>
> ​​Very few contexts in Qt care about null QVariants - this may well be the only one.​​ (An invalid QVariant - which mapped to None - is much more common.)<br>
> <br>
> Phil<br>
> <br>
> ​Hi Phil,<br>
> <br>
> Thanks, I knew about the return value from ​​<div style="font-family:tahoma,sans-serif;display:inline" class="gmail_default">​​</div>sip.enableautoconversion(), I was going to put in your suggestion when I had a moment.<br>
> <br>
> As you have shown it is not necessary in this case. However you would have problems for virtual re-implementations that are passed a QVariant as an argument rather than being passed back as a result.<br>
> <br>
> I don't get this, or we are not quite talking the same language.  Until we spotted this issue, the Python override function was causing the wrong result to be returned.  We did have to do something in this case: we had to make a call to ​sip.enableautoconversion(<wbr>QtCore.QVariant, False), which neither I nor anyone else would have known we were supposed to do here.<br>
<br>
</span>I disagree with that - although I'm not saying that the documentation couldn't be improved.<br>
<span class=""><br>
> I don't mind how we phrase it, but I just need to know what pattern I might need to look out for if I'm supposed to do similar somewhere else in Qt/PyQt?<br>
<br>
</span>Anywhere that a null QVariant has a specific meaning and is being passed as an argument to a virtual function.<br>
<span class=""><br>
> Very few contexts in Qt care about null QVariants - this may well be the only one.​ (An invalid QVariant - which mapped to None - is much more common.)<br>
> <br>
> I'll take your word for it.  All I would say is that this seems to have come about because we are trying to handle the return of NULL from a database --- right?  Might there not be more functions among all the data-handling ones where this occurs?<br>
<br>
</span><div style="font-family:tahoma,sans-serif;display:inline" class="gmail_default">​​</div>By context I mean the QtSql module.<br>
<br>
PyQt's behaviour is a compromise that works in 90+% of cases without having to use autoenableconversion(). Between us we have identified a case where using autoenableconversion() wouldn't solve the problem. However I'm not sure there is an example in Qt.<br>
<span class="HOEnZb"><font color="#888888"><br>
Phil</font></span></blockquote></div><br><div style="font-family:tahoma,sans-serif" class="gmail_default">​<div style="font-family:tahoma,sans-serif;display:inline" class="gmail_default">​</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">By context I mean the QtSql module.​</blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br clear="all"></div><div class="gmail_extra"><div style="font-family:tahoma,sans-serif" class="gmail_default">​Yes, OK, I did mean "another function in the QtSql module"​</div><br></div><div class="gmail_extra"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:tahoma,sans-serif" class="gmail_default">​<span class="gmail-">> I don't mind how we phrase it, but I just need to 
know what pattern I might need to look out for if I'm supposed to do 
similar somewhere else in Qt/PyQt?<br>
<br>
</span>Anywhere that a null QVariant has a specific meaning and is being passed as an argument to a virtual function.<br></div></blockquote><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default">​This could be very important,  I wonder if you're expecting me to understand/be aware of something which you are but I am not....</div><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default">I <i>believed</i> what we/I had discovered, specifically in my code not some other code people might write, <i>was a <b>BUG</b></i>.  And you were going to fix in next version so that I should not have to use the <span class="gmail-"><div style="font-family:tahoma,sans-serif;display:inline" class="gmail_default">​</div><span style="font-family:monospace,monospace">sip.enableautoconversion()</span></span> I have had put in.</div><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default">I now wonder whether I have been laboring under a misapprehension, and in fact you are saying my case is effectively expected behaviour, not bug, and the <span class="gmail-"><span style="font-family:monospace,monospace">sip.enableautoconversion()</span></span> I have put in is <i>meant</i> to be there, now and in the future.  <i>Is that the case, could you be very explicit about this kindly?</i></div><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default">Unlike the other guy you were debating with in 2016, I'm not wanting to argue with you about what is best or not.  I just want to know what I need to do to work properly.  I may or may not like it, but if I have to keep an eye out for:</div><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:tahoma,sans-serif" class="gmail_default">Anywhere that a null QVariant has a specific meaning and is being passed as an argument to a virtual function <i>[<b>EDIT</b>: or returned from one in the case I show, right?]</i>.</div></blockquote><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default">and that's my responsibility and I may have to use <span class="gmail-"><span style="font-family:monospace,monospace">sip.enableautoconversion()</span></span> explicitly in places, at least I know what's expected from me!!</div><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div>-- <br><div class="gmail_signature" data-smartmail="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></div>