<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif"><font face="Arial"></font><br></div><div class="gmail_quote"><div dir="ltr"><div><div class="h5"><div style="font-family:tahoma,sans-serif">On 28 November 2017 at 15:53, David Boddie <span dir="ltr"><<a href="mailto:david@boddie.org.uk" target="_blank">david@boddie.org.uk</a>></span> wrote:<br></div></div></div><div class="gmail_extra"><div><div class="h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><span>On Tue Nov 28 09:01:30 GMT 2017, J Barchan wrote:<br>
<br>
> I now understand why PyQt has to use these "tuple" returns in places. I<br>
> may not be a fan of the way Python has to do this, but at least I now know<br>
> what to look for in function declarations (non-const & references) which<br>
> will make me need to check the signature, instead of it appearing simply<br>
> "random" to me!<br>
<br>
</span>Sorry, I misread what you wrote. The "const QString &filter" parameter isn't<br>
something that will be modified, but I suppose that the argument to<br>
the selectedFilter parameter could be modified - you do get the selected<br>
filter back as the second item in the tuple in Python.<br>
<br>
I should clarify that the "const QString &" pattern in signatures appears<br>
all over the place in Qt and is used for reasons I can't remember, but<br>
probably something to do with getting old C++ compilers to generate<br>
efficient code.<br>
<br>
I suppose that the hint that something could be modified is the use of a<br>
pointer for something you would expect to be passed by value or const<br>
reference. So, QString* instead of "const QString &".<br>
<br>
For what it's worth, in the old days of KDE 3 I encountered a method of a<br>
class that accepted a reference to a QImage that you were supposed to<br>
modify. If you assigned a new QImage to the parameter holding the original<br>
one, you didn't get the result you expected. This might have worked as<br>
expected in C++, but not in Python.<br>
<br>
<a href="https://api.kde.org/3.5-api/kdelibs-apidocs/kio/html/classThumbCreator.html" target="_blank" rel="noreferrer">https://api.kde.org/3.5-api/kd<wbr>elibs-apidocs/kio/html/classTh<wbr>umbCreator.html</a><br>
<br>
I don't know why the authors didn't just define a method that returned a<br>
QImage.<br>
<br>
Sorry for the confusion.<br>
<span class="m_-4680459082988465870HOEnZb"><font color="#888888"><br>
David<br>
</font></span><div class="m_-4680459082988465870HOEnZb"><div class="m_-4680459082988465870h5">______________________________<wbr>_________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank" rel="noreferrer">https://www.riverbankcomputing<wbr>.com/mailman/listinfo/pyqt</a></div></div></blockquote></div><br></div></div><div style="font-family:tahoma,sans-serif">David, yes, I had already figured we were talking about the <em>non</em>-<font face="monospace,monospace">const *selectedFilter</font> parameter, as I wrote, rather than the <font face="monospace,monospace">const &filter</font> one, as the "reference" parameter PyQt is dealing with in the tuple return. I hadn't even noticed the Qt docs for this saying it could be returned, hidden away on one line, as it didn't occur to me anyone would be interested in getting that back from the call! Not PyQt's fault.</div><div style="font-family:tahoma,sans-serif"><br></div><div style="font-family:tahoma,sans-serif">Purely OOI, do we know whether the automated "Qt C++ to PyQt Python converter" recognises this signature pattern (i.e. non-<font face="monospace,monospace">const *</font> or <font face="monospace,monospace">&</font>) and automatically generates a tuple-return for it? Somehow I doubt it (too difficult, too reliant on C++ signature using <font face="monospace,monospace">const </font>everywhere correctly), so I'm thinking these tuple-returns are handled by the author manually?</div><br clear="all"><br><div class="m_-4680459082988465870gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div></div></div></div>
</div></div>
</div><br><br clear="all"><br>-- <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>