[Interest] Exposing types to the QJSEngine in Qt 5.5

Jaroslaw Staniek staniek at kde.org
Thu Jul 9 10:26:06 CEST 2015


Hi,
Big thanks to Simon and others for time spent on exposing types to the
qml/js engines.
And to Arend van Beelen for input.

The story continues. In an app I am suppoting .js scripts, not .qml.
Do I understand it well that with using QJSEngine (not QQmlEngine) for
value types I can use code like "new Actor()" in my scripts? (Actor is
a qgadget based
http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#value-types)

After upgrading to 5.5 I am still getting "ReferenceError: Actor is not defined"

Adding qRegisterMetaType<Actor>() prior to engine instantiation does not help.
How does the QJSEngine::toScriptValue() help?
I'd like to know more than the explanation at
https://bugreports.qt.io/browse/QTBUG-29769 or
https://codereview.qt-project.org/#/c/100347/ :)
I see that autotests in the Simon's patch only cover qml scripts, so I
am bit afraid what I'll hear :)

I feel the documentation about exposing constructors is a bit lacking.
There's a "Making a QObject Available to the Script Engine"
[http://doc.qt.io/qt-5/qtjavascript.html] but it's for instances; it
would be useful to also cover an 'official' way of exposing types.
Sometimes it's good to read what's not supported in addition to what
is supported. Especially it would be welcome for people coming from
the QtScript world.

-- 
regards, Jaroslaw Staniek

KDE:
: A world-wide network of software engineers, artists, writers, translators
: and facilitators committed to Free Software development - http://kde.org
Calligra Suite:
: A graphic art and office suite - http://calligra.org
Kexi:
: A visual database apps builder - http://calligra.org/kexi
Qt Certified Specialist:
: http://www.linkedin.com/in/jstaniek



More information about the Interest mailing list