diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2017-07-27 11:47:28 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2017-07-27 11:07:12 +0000 |
commit | 08569a0981308f2d3c164d89aa4a00f321fd8e21 (patch) | |
tree | 29d71e953f143d189fdba16f69ebfe0fd76b90fc /src/qml/doc/snippets/code | |
parent | bb199cc8ad4111808260f6255312b08c7d81dcbc (diff) |
QJSEngine: document limitation of dynamic QObject properties
Dynamic QObject properties can not be accessed through C++ (via
QJSValue) nor JavaScript.
Task-number: QTBUG-38181
Change-Id: I78bb9898fef615a647234ae8df444e8855870258
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/doc/snippets/code')
-rw-r--r-- | src/qml/doc/snippets/code/src_script_qjsengine.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/qml/doc/snippets/code/src_script_qjsengine.cpp b/src/qml/doc/snippets/code/src_script_qjsengine.cpp index c9bd7dfcd9..0305574d34 100644 --- a/src/qml/doc/snippets/code/src_script_qjsengine.cpp +++ b/src/qml/doc/snippets/code/src_script_qjsengine.cpp @@ -91,3 +91,16 @@ myEngine.evaluate("button.checkable = true"); qDebug() << scriptButton.property("checkable").toBool(); scriptButton.property("show").call(); // call the show() slot //! [5] + + +//! [6] +QJSEngine engine; + +QObject *myQObject = new QObject(); +myQObject->setProperty("dynamicProperty", 3); + +QJSValue myScriptQObject = engine.newQObject(myQObject); +engine.globalObject().setProperty("myObject", myScriptQObject); + +qDebug() << engine.evaluate("myObject.dynamicProperty").toInt(); +//! [6] |