April 5, 2011

Schneidi Schneidi
Ant Farmer
125 posts

dynamically build qml with javascript

 

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

5 replies

April 6, 2011

mbrasser mbrasser
Lab Rat
452 posts

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

April 6, 2011

Andre Andre
Robot Herder
6416 posts

I would look into the model-view stuff you have in QML. Looks like a delegate might be enough for you?

April 6, 2011

Schneidi Schneidi
Ant Farmer
125 posts

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.

April 6, 2011

Andre Andre
Robot Herder
6416 posts

Schneidi wrote:
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.

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 :-)

April 12, 2011

Schneidi Schneidi
Ant Farmer
125 posts

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 ; )

 
  ‹‹ Very strange phenomenon in QML animation with openGL      Problem getting C++ class exposed to QML ››

You must log in to post a reply. Not a member yet? Register here!