Integrating QML and C++
Qt supports bridging between C++ classes with the QML engine. This combination allows developers to take advantage of both the simplicity of QML and the flexibility of C++. You can even integrate features that are not supported by Qt from external components, then pass the resulting data to Qt Quick to be displayed in the UI. In this example, we will learn how to export our user interface components from QML to the C++ framework and manipulate their properties before displaying them on screen.
How to do it…
Let’s go through the following steps:
- Once again, we will start everything from scratch. Therefore, create a new Qt Quick application project in Qt Creator and open up
Screen01.ui.qml
with Qt Design Studio. Then, open upScreen01.ui.qml
. - We can keep the mouse area and text widget but place the text widget at the bottom of the window. Change the
Text
property of the text widget to Change this text using C++ and set its font...