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 an external library, then pass the resulting data to Qt Quick to be displayed in the UI. In this example, we will learn how to export our UI components from QML to the C++ framework and manipulate their properties before displaying them on screen.

How to do it…

  1. Once again, we will start everything from scratch. Therefore, create a new Qt Quick application project in Qt Creator and open up MainForm.ui.qml.
  2. We can keep the mouse area and text widget, but place the text widget at the bottom ...

Get Qt5 C++ GUI Programming Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.