[Development] QML and JavaScript extensions

Kevin Krammer kevin.krammer at kdab.com
Fri Nov 15 10:43:53 CET 2013


On Monday, 2013-11-11, 10:38:28, Topi Mäenpää wrote:

> I've been using Qt's JavaScript engines to provide a scripting interface
> to Into about ever since QScriptEngine was introduced. It provided
> fairly good extension interfaces and I was able to implement almost
> everything I wanted using the public API.
> 
> Enter QML. From its introduction, it has been clear that using
> JavaScript extension from QML applications was not a planned use case.
> In Qt4, QDeclarativeEngine used QScriptEngine to evaluate JavaScript,
> but it deliberately hid that as an "implementation detail". I brought up
> this issue on the forums a couple of years ago
> (http://qt-project.org/forums/viewthread/4333), and talked with
> developers at Nokia and later Digia in person, but the situation hasn't
> got any better. On the contrary, actually.

I think the existence of JavaScript context in QML should be considered a 
feature of QML, not of Qt or the application itself.

There is a module specifically created for the purpose of general scripting 
using JavaScript and that is QtScript.

As you wrote yourself, it provides more or less everything you want it to do.
In pre-QML times you've had to create a C++ application, probably using 
QtWidgets if you had UI, and explicitly create, initialize and run your script 
engine instance.

I see no reason to do anything different just because of a switch in UI 
technology.
You can still create, initialize and run your script engine instance. You 
could even make it or a customized wrapper instantiable through QML.

Please correct me if I am wrong, but the issue you have with keeping doing 
what has proven to be a good way is the "deprectated" label QtScript currently 
has.
If so, I would imagine that this status could be changed to actively mainained 
again.
Qt development is a combined effort of multiple parties.
If one or more parties have interest in continued development of a scripting 
module and provide the resources to do it, then I am sure that would change 
the official status of said module.

Cheers,
Kevin

-- 
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/cf969511/attachment.bin>


More information about the Development mailing list