Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qjsengine.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
5
8 object.setProperty("num", 42);
9 QJSValue function = engine.evaluate("(o) => o.num *= 2 ");
10 QJSValueList args = { object };
11 QJSValue result = function.call(args);
13 Q_ASSERT(result.equals(expected) && !result.strictlyEquals(expected));
14
16
The QJSEngine class provides an environment for evaluating JavaScript code.
Definition qjsengine.h:26
QJSValue newObject()
Creates a JavaScript object of class Object.
QJSValue evaluate(const QString &program, const QString &fileName=QString(), int lineNumber=1, QStringList *exceptionStackTrace=nullptr)
Evaluates program, using lineNumber as the base line number, and returns the result of the evaluation...
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
QJSValue call(const QJSValueList &args=QJSValueList()) const
Calls this QJSValue as a function, passing args as arguments to the function, and using the globalObj...
Definition qjsvalue.cpp:705
void setProperty(const QString &name, const QJSValue &value)
Sets the value of this QJSValue's property with the given name to the given value.
Definition qlist.h:75
QJSValue expected
Definition qjsengine.cpp:12
QJSValueList args
Definition qjsengine.cpp:10
QJSEngine engine
[qjs-engine]
Definition qjsengine.cpp:6
GLuint64EXT * result
[6]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47