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. Loop or linear traverse to fill qml-objects
Qt 6.11 is out! See what's new in the release blog

Loop or linear traverse to fill qml-objects

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.3k Views 1 Watching
  • 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
    sk51178
    wrote on last edited by
    #1

    Hi,

    I am new to Qt and Qml, but I am very excited after experiencing the power of these toolkit. I have one question regarding QML. From what I understand, there is nothing like a loop or iterator in QML , and we have to rely on JavaScript or C++(my preferred lang.) to do that work.

    Say I have a text file with each line mentioning dimension of different rectangles, and their colors that i need to draw in certain fashion on the screen. I am able to load these details into some C++ structure object, and now I am trying to draw them using grid, or simply in linear fashion. How can I keep reading details of next rectangle from Qml, and then stop when the last rectangle is read? Is signal/slot helpful in doing so?

    Please guide me. Any link to sample code example will be helpful in this regards.

    Regards.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stefan14808
      wrote on last edited by
      #2

      i am very new to Qt and QML as well.
      But this sound to me as your text file could be the model of a component using a delegate to draw one rectangle.
      if you are not already familiar with the model/delegate concept you could check the docu.
      maybe this helps

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sk51178
        wrote on last edited by
        #3

        Thanks Stefan. I will have a look into this.

        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