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



  • 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



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



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.