So far, we were only evaluating some standalone scripts that can make use of built-in JavaScript features. Now, it is time to learn to use data from your programs in the scripts. This is done by exposing different kinds of entities to and from scripts.
Exposing C++ objects and functions to JavaScript code
Accessing C++ object's properties and methods
The simplest way to expose a C++ object to JavaScript code is to take advantage of Qt's meta-object system. QJSEngine is able to inspect QObject instances and detect their properties and methods. To use them in scripts, the object has to be visible to the script. The easiest way to make this happen is to add it to the engine's global object. As you remember, all...