PDA

View Full Version : How to create C++ objects dynamically and bind with QML UI



keith77
4th April 2013, 14:55
Hi, I'm a relative beginner with Qt Creator, and have some experience with C++ but I'm new to QML.
I've been going through the following Dynamic Scene Example:

http://qt-project.org/doc/qt-4.8/declarative-toys-dynamicscene.html

I follow how the objects are created dynamically using QML. I want to know is it possible to create
similar objects dynamically using C++ funtions in Qt Creator, as I cant seem to find any examples
of this.

My goal is to extend QML using C++.
ie. C++ functions -> QML properties.

Thank you.

wysota
4th April 2013, 15:18
What do you mean by "similar objects"?

keith77
5th April 2013, 20:19
I basically mean any generic object that can be open, closed, attached etc. that is created using C++. I'm looking for examples to learn from, and have already found some that creates the objects using QML, such as the Dynamic scene example.

Thanks.

wysota
5th April 2013, 22:34
The dynamic scene example doesn't create any objects in C++. If you want to create qml items in C++ then you can of course do that however I don't understand why you'd want to do that really. Usually we do expose some objects from C++ to the declarative engine however they are usually not qml items or are at least created from QML code using QDeclarativeComponent or similar.