[Development] QML and JavaScript extensions

Kevin Krammer kevin.krammer at kdab.com
Fri Nov 15 11:00:40 CET 2013

On Thursday, 2013-11-14, 21:20:25, Topi Mäenpää wrote:

> > But that's a long term plan, v4vm isn't even released yet (new in 5.2
> > remember) and there's still tons of work to do. Until v4vm is ready to
> > take over from QtScript, which will still be a while, I believe the
> > recommendation is to keep using QtScript. It's deprecated and "done"
> > because we've reallocated development priorities, but until we've
> > finished its replacement it is your best option. Even though it means
> > using old or no QML, it sounds like the JS support is more important
> > for you.
> I considered the options carefully before switching to Qt5. I talked to
> Digia engineers and they told me the same you are telling now: QtScript
> will be deprecated and definitely not accessible from QML. Therefore, it
> was completely out of question. I don't think building anything serious
> on a deprecated API is a good idea anyway.

That could have been a miscommunication. What they probably meant was that the 
standard QtQuick module would not have a QML type for QScriptEngine.

QScriptEngine can certainly be accessed from QML. Sure evaluate is currently 
neither a slot nor a Q_INVOKABLE, but that would easily added and/or worked 
around by a simple subclass or wrapper.

Remember that any default constructible QObject class can be instantiated by 
QML, its slots, signals, properties and Q_INVOKABLEs becoming available.
QML is just the "glue" between object instances, it doesn't care what those 
objects do internally.

> Qt is heading to a JavaScript-based future. Widgets are deprecated and
> replaced by QML. In this situation, a good extension interface to the
> JavaScript engine that runs QML is a really important feature.

I have to disagree with a couple of items here.

Qt has already had JavaScript based scripting support for ages, so it is not 
heading into using it.  As for JS in QML, any sensibly designed application 
will avoid doing business logic process in the UI. That was already not a good 
idea when using C++, no need to continue bad practise when the new UI 
technology hands you a nice way to correct that.

I also wouldn't consider widgets to be deprecated, at least not yet. And 
nicely use QML with widgets as the UI elements, it is not replacing one with 
the other either (though you probably meant QtQuick when you wrote QML there).


Kevin Krammer | kevin.krammer at kdab.com | Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5918 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131115/bc2dc7ba/attachment.bin>

More information about the Development mailing list