qt group oyj - 6 QML Book Updates - MarketScreener .

C++ Coding

35 Views

        

Qt 6 QML Book Updates

Friday March 18, 2022 by Johan Thelin | Comments

The Qt 6 QML Book is about QML and related topics such as how to integrate languages such as C++ and Python to QML, the Qt for MCUs offering, and more. It has been a few months since the last update, so we're going to talk about what happened since the last time around. If you want to go ahead and start reading immediately, you can find the free online book here.

Qt for MCUs

The most significant addition to the book is the section on Qt for MCUs. Modern user interfaces are ubiquitous today, and as a consequence, users expect fluid, touch-based user interfaces of smaller and smaller devices. Driving user interfaces from microcontroller class devices is doable, but is often complex. This is where Qt for MCUs and Qt Quick Ultralite enters the picture. It combines the convenience of Qt Quick and QML, with the ability to run on very small systems, that are too resource restricted to run Linux or other operating systems that Qt traditionally targets.

Qt for MCUs has been around for a while now and recently reached version 2.0. To make it easier to get started with Qt for MCUs, we've just recently added a chapter on the topic to the Qt 6 book, where we walk through setting up the environment and some typical use cases.

Qt for MCUs targets the bare metal, or small real-time operating systems such as FreeRTOS. This means that the application's footprint is much smaller, but also that the environment is more restricted. Some of the key differences between Qt and Qt for MCUs are:

  • Qt for MCUs is only a front-end framework. Programs must rely on STL and other 3rd party libraries for the functionality that the classic, non-graphical Qt modules provide.
  • Qt for MCUs compiles QML to a minimized binary, meaning that there is no QML interpreter onboard. This requires things to be more strictly defined, less dynamic, and there are caveats when working with dynamic data.
  • Qt for MCUs comes with Qt Quick Ultralite, a sub-set of Qt Quick.

Generally, all the limitations above do not restrict development, given the capabilities of the target systems. However, one needs to be aware of them and capable of handling the caveats they imply. This is described in detail in the reference documentation. In the Qt 6 Book, the restrictions, and solutions to them, are brought up in the context of the examples.

The examples are built up from a simple "Hello World" and include a demonstration of how to mix C++ and QML to exchange properties, signals, and function calls, as well as an example of a C++ model being used to populate a view on the QML side.

Compared to a classic Qt code base, one of the biggest changes is that the QObject base class is no longer used. Instead, several classes for creating signals, properties, models, and more are provided. These classes are based around modern C++ and do not involve the meta-object compiler. At the same time, a new compiler is used to extract meta-information about interfaces and models exposed from C++ to QML, and alongside a compiler for converting QML to C++. This means slightly less dynamic code at runtime but a lower footprint and a better result for smaller embedded targets.

The chapter also discusses the build environment. As Qt for MCUs compiles QML to C++ prior to deploying it to the target, there are many CMake macros used to register interfaces, compile QML, and such.

Qt Quick Shapes

Another new chapter covers the Qt Quick Shapes module. The module lets you create and work with path-based shapes in QML. This takes QML beyond rectangles to the land of free-form shapes.

This has been possible to achieve using pre-rendered graphics or SVGs for resolution independence. However, using the Qt Quick Shapes module, you can modify the shapes directly using QML's bindings. This lets you adjust shapes, positions, colors, and any other property you can think of on the fly. This includes being able to use QML animations.

The new chapter complements the older Canvas chapter. The Canvas module is still there and offers the API from the browser canvas, which is very handy for integrating Javascript/web visualization tools into QML scenes.

Next Steps

The current development of the book is to create a section on Qt Quick 3D, which is a large topic that is new to the book. The purpose is to create an introduction to the topic step-by-step so that it is easy to start learning about the subject.

There have been many contributions in the form of corrections and bug reports - these are much appreciated and will be addressed before the next release of the book. Thank you!

Share with your friends

Blog Topics: