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. ListModel.append "for" loop to add "attributes"?[SOLVED]
QtWS25 Last Chance

ListModel.append "for" loop to add "attributes"?[SOLVED]

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 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.
  • C Offline
    C Offline
    cmer4
    wrote on last edited by
    #1

    Hey All,

    I know how to append a model with attributes element w/o issues using different values (below example is taken from manuals):
    @fruitModel.append(..., "attributes":[{"name":"spikes","value":"7mm"},{"name":"color","value":"green"}]);@

    But in cases I need to run "for" loop cycle to append attributes section only I run into problems;(

    How can I run a cycle like the below one but making the changes to one element's attributes and not adding attributes to each new list element created by the cycle (current effect of the code below) =( ??

    @

    for (var i=firstModel.count-1; i>=0; i--)
    secondModel.append({"date": currentdate, "attributes":[{"parameter1":firstModel.get(i).name,"parameter2":firstModel.get(0).quantity}]})

    @

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Diph
      wrote on last edited by
      #2

      @secondModel.get(i).attributes.append(...)@

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cmer4
        wrote on last edited by
        #3

        Thanks a lot for the tip! Solved now;)

        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