Enable gadget wrapping for custom value types
authorSimon Hausmann <simon.hausmann@theqtcompany.com>
Thu, 20 Nov 2014 09:42:34 +0000 (10:42 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Fri, 2 Jan 2015 14:06:46 +0000 (15:06 +0100)
commit2b5fb185627f8adfb6c5b3d62990a58429bf4ea7
tree63ae9357fbcb652b48b01a8a6de2da026fb93f40
parent9a2701c1c3c7c805335fb2c1a1dfd1e712e4db6b
Enable gadget wrapping for custom value types

[ChangeLog][QtQml] Custom C++ value types annotated with Q_GADGET are now fully
accessible in the QML and QJSEngine JavaScript environment.

QJSEngine::toScriptValue can be used for injection and fromScriptValue to
extraction. The QML "built-in" gadget wrappers for QPoint and the gui types are
not exposed this way, toScriptValue(point) will still return an opaque QVariant
wrapper. We could expose the core types right away, but then we would be
lacking an API to enable use of the Gui types that are registered in QtQuick.

It would be better to make the core types in qtbase gadgets and thus enable
them without the need for hooks and init functions to be called by the user.

Task-number: QTBUG-29769
Change-Id: I8179cd599bdc1209ff61cfdbdda419cb400296bb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/doc/src/cppintegration/data.qdoc
src/qml/jsapi/qjsengine.cpp
src/qml/jsapi/qjsengine_p.h
src/qml/qml/qqmlvaluetype.cpp
src/qml/qml/qqmlvaluetypewrapper.cpp
src/qml/qml/qqmlvaluetypewrapper_p.h
src/qml/qml/v8/qv8engine.cpp
tests/auto/qml/qqmlvaluetypes/data/customvaluetype.qml [new file with mode: 0644]
tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro
tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp