Qt Quick and C++
While QML has a lot of built-in functionality available, it will almost never be enough. When you're developing a real application, it always needs some unique functionality that is not available in QML modules provided by Qt. The C++ Qt classes are much more powerful, and third-party C++ libraries are also always an option. However, the C++ world is separated from our QML application by the restrictions of QML engine. Let's break that boundary right away.
Accessing C++ objects from QML
Let's say that we want to perform a heavy calculation in C++ and access it from our QML calculator. We will choose factorial for this project.
Note
The QML engine is really fast, so you can most likely calculate factorials directly in JavaScript without performance problems. We just use it here as a simple example.
Our goal is to inject our C++ class into the QML engine as a JavaScript object that will be available in our QML files. We will do that exactly like we did it in Chapter 10, Scripting...