aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/doc/snippets/code/src_script_qjsengine.cpp13
-rw-r--r--src/qml/jsapi/qjsengine.cpp7
2 files changed, 19 insertions, 1 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]
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp
index e4c150057a..c678f8037a 100644
--- a/src/qml/jsapi/qjsengine.cpp
+++ b/src/qml/jsapi/qjsengine.cpp
@@ -175,9 +175,14 @@ Q_DECLARE_METATYPE(QList<int>)
called from the script to create a new QObject instance with
JavaScriptOwnership.
+ \snippet code/src_script_qjsengine.cpp 5
+ \section2 Dynamic QObject Properties
- \snippet code/src_script_qjsengine.cpp 5
+ Dynamic QObject properties are not supported. For example, the following code
+ will not work:
+
+ \snippet code/src_script_qjsengine.cpp 6
\section1 Extensions