Dynamically build qml with javascript
-
wrote on 5 Apr 2011, 19:33 last edited by
Hey folks,
is there a way to build qml UIs dynamically using javascript.
In my case, I have a QList of objects in C++ which I wanna convert into qml elements.
I would iterate through the objects of the QList and build for example qml Rectangles for each object.How could I implement something like this.
Thanks for help
-
wrote on 5 Apr 2011, 23:36 last edited by
Hi,
I'm not sure if it will help in this case, but if you haven't read it already I would suggest looking at http://doc.qt.nokia.com/4.7-snapshot/qdeclarativedynamicobjects.html as a first step, as it goes over the various ways to work with dynamic objects in QML.
Regards,
Michael -
wrote on 6 Apr 2011, 08:20 last edited by
I would look into the model-view stuff you have in QML. Looks like a delegate might be enough for you?
-
wrote on 6 Apr 2011, 17:52 last edited by
Hey Michael,
maybe the examples in your link could be helpful. Thanks so far.
Hi Andre, afaik delegates are representations of list entries.
What I wanna do is to implement the QList entries from C++ as different elements
like screens or buttons etc. -
wrote on 6 Apr 2011, 18:07 last edited by
[quote author="Schneidi" date="1302112337"]Hey Michael,
maybe the examples in your link could be helpful. Thanks so far.
Hi Andre, afaik delegates are representations of list entries.
What I wanna do is to implement the QList entries from C++ as different elements
like screens or buttons etc. [/quote]Ok, it is just that at first, you were talking about rectangles. You are right, delegates are used to display items from a model, but based on your first description, that was basically all you needed :-)
-
wrote on 12 Apr 2011, 06:22 last edited by
Hey guys,
I tried the examples from the "Dynamic Object Management in QML" page.
It worked pretty well, I'm really impressed about the integrity of the hole QML and JavaScript system.Thanks for the hint Michael ; )
3/6