Qt
6.x
The Qt SDK
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
// Copyright (C) 2017 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4
#include <QtQml>
5
6
int
main
(
int
argc,
char
*argv[])
7
{
8
QCoreApplication
app
(argc, argv);
10
QJSEngine
engine
;
11
qDebug
() <<
"the magic number is:"
<<
engine
.
evaluate
(
"1 + 2"
).
toNumber
();
13
return
0;
14
}
QCoreApplication
\inmodule QtCore
Definition
qcoreapplication.h:48
QJSEngine
The QJSEngine class provides an environment for evaluating JavaScript code.
Definition
qjsengine.h:26
QJSEngine::evaluate
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...
Definition
qjsengine.cpp:508
QJSValue::toNumber
double toNumber() const
Returns the number value of this QJSValue, as defined in \l{ECMA-262} section 9.3,...
Definition
qjsvalue.cpp:505
main
int main()
[0]
Definition
doc_src_objecttrees.cpp:5
qDebug
#define qDebug
[1]
Definition
qlogging.h:160
app
QApplication app(argc, argv)
[0]
engine
QJSEngine engine
[0]
Definition
src_script_qjsvalue.cpp:14
qtdeclarative
src
qml
doc
snippets
qtjavascript
evaluation
main.cpp
Generated by
1.9.7