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



  • 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}]})

    @



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



  • Thanks a lot for the tip! Solved now;)


Log in to reply
 

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