[Qt-qml] Accessing QML objects from C++

warwick.allison at nokia.com warwick.allison at nokia.com
Fri May 28 03:22:09 CEST 2010


> 	we recommend that you not make your C++ layer use knowledge of the internals of
> 	the QML files, so that you have more flexibility in rewriting the UI.
> 
> Thank you. Very wise counsel. I will need to re-think my design.

If you keep the interface of your QML just the set of properties in the root item, you can provide a narrower API, keeping the freedom to modify the QML:

Item {
   id: root
   property string title: "Unknown"
   ...
        Text { text: root.title }
   ...
}

(or use property aliases to provide bi-directional access)

--
Warwick




More information about the Qt-qml mailing list