[Development] Behaviour change in QML in Qt 5.8 regarding null

Jocelyn Turcotte jturcotte at woboq.com
Thu Sep 29 10:29:52 CEST 2016


One of the reasons to use QVariant is that it's usually what is needed to connect a C++ signal to a QML function or to use invokeMethod, I could only ever get this to work by passing all arguments as QVariants.
See for example: http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html#invoking-qml-methods

Connecting QML signal to a C++ slot also recommends (requires?) using a QVariant for arguments: http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html#connecting-to-qml-signals

Would there be a way that I'm not aware to use QJSValue in those situations too?
Sure it's the other way around, but for the sake of consistency I don't like to use QVariant for QML input functions while using QJSValue for arguments of output functions.

Jocelyn

> On 29 Sep 2016, at 03:13, Chris Adams <chris.adams at qinetic.com.au> wrote:
> 
> I'm certain that it's possible.  I suspect the reason why the code used QVariant is that when it was originally written (in Qt 4.7 days, IIRC), QJSValue didn't exist, and it simply hasn't been ported to newer interfaces since then.  Without knowing too much about the QML bindings in QtPIM, I am going to assume that there is at least some effort required to port all of the usages and update all of the unit tests.
> 
> On Thu, Sep 29, 2016 at 1:50 AM, Thiago Macieira <thiago.macieira at intel.com> wrote:
> On quarta-feira, 28 de setembro de 2016 15:42:06 PDT Simon Hausmann wrote:
> > I don't think the QVariant interface is deprecated, but it just inherently
> > unsuitable for JavaScript specific things such as distinguishing undefined
> > from null or storing function closures. That is why the engine supports
> > both, for different purposes.
> 
> Chris, is it possible to use the QJSValue interface instead? Why did the code
> use QVariant?
> 
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel Open Source Technology Center
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development




More information about the Development mailing list