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

Exposing C++ objects to QML

There are two main paths to expose C++ code to QML: we can either expose already instantiated C++ objects to a QML engine's context or, alternatively, register C++ classes as QML types, and then create object instances on the QML side.

Each of the two techniques has got its advantages and usage scenarios. Broadly speaking, we'd want to pass C++ object instances to QML if we wanted some C++ application layer to be in control of the object's lifetime; conversely, we would wrap a C++ class as a QML type if we wanted some QML layer run by the QML/JS engine to be in charge of the object's lifetime.

Despite the general rules outlined earlier, it is still possible to set the ownership of an object's lifetime (C++ vs. ...

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