Integrating Qt and Qt Script

So far, we were only evaluating some standalone scripts that could make use of the features built in JavaScript. 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 objects

The simplest way to expose data to Qt Script is to take advantage of Qt's meta-object system. Qt Script 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 execution context. The easiest way to make this happen is to add it to the engine's global object or to some context's activation object. As you remember, all data between the script engine and C++ is exchanged ...

Get Game Programming Using Qt now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.