aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2023-08-15 09:21:24 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-08-15 15:48:51 +0000
commit6f37f3a19ccdeeedc764e3ba4dcb1e733c053d6e (patch)
treea8460d7668143025363f178c2ec091bdd9ae3784
parent51d92295f9a0cd5afc22cb4849677f7ee159d8b0 (diff)
QJSEngine::evaluate: Cross-reference QQmlExpression
QJSEngine::evaluate is meant for plain JavaScript; guide readers wanting to use it with QML to the correct place. Change-Id: If8016a4cca2999d95bac47e83159b1e10eb5a0d5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit fead337daa3e339676b05f0f152864455752dfb3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qml/jsapi/qjsengine.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp
index 3d75bf4032..374d170019 100644
--- a/src/qml/jsapi/qjsengine.cpp
+++ b/src/qml/jsapi/qjsengine.cpp
@@ -474,6 +474,9 @@ static QUrl urlForFileName(const QString &fileName)
The script code will be evaluated in the context of the global object.
+ \note If you need to evaluate inside a QML context, use \l QQmlExpression
+ instead.
+
The evaluation of \a program can cause an \l{Script Exceptions}{exception} in the
engine; in this case the return value will be the exception
that was thrown (typically an \c{Error} object; see
@@ -504,6 +507,8 @@ static QUrl urlForFileName(const QString &fileName)
exception value will still be returned. Use \c exceptionStackTrace->isEmpty()
to distinguish whether the value was a normal or an exceptional return
value.
+
+ \sa QQmlExpression::evaluate
*/
QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, int lineNumber, QStringList *exceptionStackTrace)
{