[PyQt] Conversion from QML

pwuertz pwuertz at gmail.com
Mon Mar 9 12:59:40 GMT 2015


Phil Thompson-5 wrote
> 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.

I don't really understand why the reason for this change is supposed to be
related to the transition from Qt5.3 to Qt5.4. Wouldn't this imply a break
of the Qt API at C++ level? That doesn't sound likely.

As far as I know, calling QML methods from C++ is done by using
QMetaObject::invokeMethod (see
http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html#invoking-qml-methods).
I assume this is also what PyQt uses when calling an unknown method of a
QQuickItem instance?

When using QMetaObject::invokeMethod the user must explicitly define the
types of arguments and return values. It seems that the choice of QJSValue
or QVariant as the return type is entirely up to PyQt, or is there something
I'm missing?

So if this is true why is PyQt using QJSValue as default type now? Is there
any reason for using QJSValue? Even the example in the Qt documentation uses
QVariant. If this change wasn't intentional, could we get the old behaviour
back in a bugfix release? Breaking the API would cause very cumbersome code,
as we'd have to explicitly check for the PyQt version every time when
calling into qml methods and handle the return values differently. For use
cases where the default choice of QVariant isn't applicable a PyQt user
could still call invokeMethod directly, right?




--
View this message in context: http://python.6.x6.nabble.com/Conversion-from-QML-tp5081765p5088702.html
Sent from the PyQt mailing list archive at Nabble.com.


More information about the PyQt mailing list