It is also possible to create QML objects from C++ and access the existing objects living in the QML engine (for example, those declared in some QML file). However, in general, doing this thing is bad practice. If we assume the most common case, which is that the QML part of our application deals with a user interface in Qt Quick for the logic written in C++, then accessing Qt Quick objects from C++ breaks the separation between logic and the presentation layer, which is one of the major principles in GUI programming. The user interface is prone to dynamic changes, relayouting up to a complete revamp. Heavy modifications of QML documents, such as adding or removing items from the design, will then have to be ...
Accessing QML objects from C++
Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.