O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding elements to the composition

The most common way of using QML is declaratively. You have seen many examples of this right now; object declarations and simple property bindings work this way. There are times, however, where a dynamic approach is either preferred or required. Qt provides a few APIs for the dynamic creation of QML objects from JavaScript. We see an example of this in the preceding code snippet, by calling the createObject method of a Component type.

But what is a QML Component (http://doc.qt.io/qt-5.9/qml-qtqml-component.html)? It is an inline type definition; instead of using a .qml file to create our object from, we make the wanted component definition (Element, in the preceding example) available from within our current ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required