Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Dynamically build qml with javascript
QtWS25 Last Chance

Dynamically build qml with javascript

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 3 Posters 3.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Schneidi
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Schneidi
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Schneidi
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved