From fead337daa3e339676b05f0f152864455752dfb3 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 15 Aug 2023 09:21:24 +0200 Subject: QJSEngine::evaluate: Cross-reference QQmlExpression QJSEngine::evaluate is meant for plain JavaScript; guide readers wanting to use it with QML to the correct place. Pick-to: 6.2 6.5 6.6 Change-Id: If8016a4cca2999d95bac47e83159b1e10eb5a0d5 Reviewed-by: Ulf Hermann --- src/qml/jsapi/qjsengine.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/qml/jsapi/qjsengine.cpp') 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) { -- cgit v1.2.3