Qt Script▲
Qt provides support for application scripting with ECMAScript. The following guides and references cover aspects of programming with ECMAScript and Qt.
This module is not actively developed. It is provided for backwards compatibility with Qt 4 only. For new code, use QJSEngine and related classes in the Qt QML module instead.
Licenses and Attributions▲
Qt Script is available under commercial licenses from The Qt Company. In addition, it is available under free software licenses. Since Qt 5.4, these free software licenses are GNU Lesser General Public License, version 3, or the GNU General Public License, version 2. See Qt Licensing for further details.
Furthermore, Qt Script in Qt 5.12.12 does contain third-party modules under following permissive licenses:
-
JavaScriptCore, version Snapshot from 2011-01-27: GNU Library General Public License v2 or later
Scripting Classes▲
The following classes add scripting capabilities to Qt applications.
-
QScriptEngineAgent: The QScriptEngineAgent class provides an interface to report events pertaining to QScriptEngine execution.
-
QScriptProgram: The QScriptProgram class encapsulates a Qt Script program.
Language Overview▲
Qt Script is based on the ECMAScript scripting language, as defined in standard ECMA-262. Microsoft's JScript, and Netscape's JavaScript are also based on the ECMAScript standard. For an overview of ECMAScript, see the ECMAScript reference. If you are not familiar with the ECMAScript language, there are several existing tutorials and books that cover this subject, such as JavaScript: The Definitive Guide.
Basic Usage▲
To evaluate script code, you create a QScriptEngine and call its evaluate() function, passing the script code (text) to evaluate as argument.