<div dir="ltr">Hello Phil, <br><br>I am not a experienced at all with qml, pyqt or qt, but after reading more docs, and try things out, I am quite sure what I think would be the correct to do in this case....<br><br>I would let the implementation be as it is now, meaning always returning the QJSValues.<br> <br>Why: <br><br>- as you write, there must be a reason, that the functions returns QJSValues. ( Maybe it is the "monadic" evaluation environment, making people able to create javascript object, and execute functions and memberfunctions on them deeply inside qml - I do not know if there exists a fair usage for that..:-). )<br><br>- you wrote that old return value was a QVariant, ( I was not aware of that, and not aware of QVariants automatic conversion to python types ). The QJSValue has a toVariant function, that converts to right type, as you described above.<br>So calling a the toVariant() function on the returned QJSValue, to get objects packed out to dicts, arrays to lists, strings to str etc.etc seems to me very fair, avoiding breaking anything with Qt v.5.4.<br><br><br>Using the example .<br><br>data = item.getStuff() # Qt v.5.3<br><br>data = item.getStuff().toVariant() # Qt v.5.4 <br><br>the 2 data is both "python values". If I knew this QVariant thing, ( read: If I had read the docs more carefully ), I would never have asked this question. Just used it - it is simple, it actually follows the documentation<br><br><br>Best Regards<br><br>Brian<br><br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 8, 2015 at 5:23 AM, 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 08/01/2015 5:36 am, B. B. wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Didn't you always have to call toString() etc. to get the actual values,<br>
even with Qt v5.3?<br>
</blockquote>
><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If so then implementing the mapping protocol should allow you to write<br>
code that would work with both v5.3 and v5.4 without needing to be changed.<br>
<br>
Phil<br>
<br>
</blockquote>
<br>
<br>
No, It was not neccesary, because there was no QJSValue in what the<br>
function returned.<br>
</blockquote>
<br></span>
I was misled by your app.py example calling property() in section 2.<div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
With the combination :<br>
Qt :<br>
5.3<br>
<br>
PyQt :<br>
PyQt-gpl-5.4-snapshot-<br>
15b37c22d541 ( from around 17 of november )<br>
<br>
Sip:<br>
sip-4.16.5-snapshot-<u></u>c005a6d2e53e ( around 17 of november )<br>
<br>
All values returned were already "python values":<br>
( from the example, earlier in this thread ):<br>
<br>
<br>
The return value with combination Qt5.3 , PyQt, sip from 17/11 )<br>
<br>
{'texts': [<PyQt5.QtCore.QObject object at 0x7f1d6c11fc18>], 'good': 'yes'}<br>
<br>
<br>
<br>
The return value with Qt5.4 , PyQt, sip from about 25/12, is that QJSValue:<br>
<br>
<PyQt5.QtQml.QJSValue object at 0x7f2563921898><br>
<br>
This is the QJSValue type, one have to pack out, to get the "python one"<br>
like the one above...<br>
<br>
<br>
<br>
Because the return value earlier contained "pure python", like str, dict<br>
and list, along with PyQt5 objects, like QObjects,<br>
I thought the PyQt5 earlier did a processing, prepareing the result. But<br>
that was somehow lost in progress since november.<br>
<br>
This was a pure guess, I have really not looked into changes from qt-5.3 to<br>
qt-5.4, or in any PyQt sources....<br>
<br>
<br>
Because of you question, I see a little hope for the smooth easier old way<br>
of returning :-)..<br>
I will try to run the example a crossed sources, ( New PyQt5 with qt-5.3 ,<br>
or PyQt5 from november with qt-5.4 - if that is possible ). Just to<br>
verify...<br>
</blockquote>
<br></div></div>
I could do the automatic conversion of bool, QDateTime, QObject etc. and leave it as a QJSValue if no obvious conversion could be done. However there must have been a reason for the change in Qt v5.4 - maybe because the isError(), isNull(), isUndefined() states were being lost by Qt v5.3 automatically converting to a QVariant.<br>
<br>
I don't have enough personal experience with using QML to know what the right thing to do is, so feedback needed.<span class="HOEnZb"><font color="#888888"><br>
<br>
Phil<br>
</font></span></blockquote></div><br></div>