summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativeexpression.cpp
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-07-06 05:30:33 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-07-06 05:30:33 (GMT)
commitc9d487b6ed3ac9bb666c2a1fe08252f3c6dcb455 (patch)
tree68ca42e8c1bbfcf99e6db77be213688d437feeba /src/declarative/qml/qdeclarativeexpression.cpp
parent6b2ec2ab8df94233d6ba7960d5bfb3c7461b76ec (diff)
downloadQt-c9d487b6ed3ac9bb666c2a1fe08252f3c6dcb455.zip
Qt-c9d487b6ed3ac9bb666c2a1fe08252f3c6dcb455.tar.gz
Qt-c9d487b6ed3ac9bb666c2a1fe08252f3c6dcb455.tar.bz2
doc improvements
Diffstat (limited to 'src/declarative/qml/qdeclarativeexpression.cpp')
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index 8ae5f2f..96cdec1 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -214,8 +214,30 @@ QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContex
/*!
\class QDeclarativeExpression
- \since 4.7
+ \since 4.7
\brief The QDeclarativeExpression class evaluates JavaScript in a QML context.
+
+ For example, given a file \c main.qml like this:
+
+ \qml
+ import Qt 4.7
+
+ Item {
+ width: 200; height: 200
+ }
+ \endqml
+
+ The following code evaluates a JavaScript expression in the context of the
+ above QML:
+
+ \code
+ QDeclarativeEngine *engine = new QDeclarativeEngine;
+ QDeclarativeComponent component(engine, QUrl::fromLocalFile("main.qml"));
+
+ QObject *myObject = component.create();
+ QDeclarativeExpression *expr = new QDeclarativeExpression(engine->rootContext(), myObject, "width * 2");
+ int result = expr->evaluate().toInt(); // result = 400
+ \endcode
*/
/*!