Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Game Programming using Qt 5 Beginner's Guide - Second Edition

You're reading from  Game Programming using Qt 5 Beginner's Guide - Second Edition

Product type Book
Published in Apr 2018
Publisher
ISBN-13 9781788399999
Pages 714 pages
Edition 2nd Edition
Languages

Table of Contents (18) Chapters

Preface 1. Introduction to Qt 2. Installation 3. Qt GUI Programming 4. Custom 2D Graphics with Graphics View 5. Animations in Graphics View 6. Qt Core Essentials 7. Networking 8. Custom Widgets 9. OpenGL and Vulkan in Qt applications 10. Scripting 11. Introduction to Qt Quick 12. Customization in Qt Quick 13. Animations in Qt Quick Games 14. Advanced Visual Effects in Qt Quick 15. 3D Graphics with Qt 16. Pop quiz answers
17. Other Books You May Enjoy

Evaluating JavaScript expressions

To use Qt QML in your programs, you have to enable the script module for your projects by adding the QT += qml line to the project file.

C++ compilers do not understand JavaScript. Therefore, to execute any script, you need to have a running interpreter that will parse the script and evaluate it. In Qt, this is done with the QJSEngine class. This is a JavaScript runtime that handles the execution of script code and manages all the resources related to scripts. It provides the evaluate() method, which can be used to execute JavaScript expressions. Let's look at a "Hello World" program using QJSEngine:

#include <QCoreApplication>
#include <QJSEngine>

int main(int argc, char **argv) {
    QCoreApplication app(argc, argv);
    QJSEngine engine;
    engine.installExtensions(QJSEngine::ConsoleExtension);
    engine.evaluate...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}