arrays - How do I define QML states dynamically using JavaScript -


is there way of creating state object dynamically using javascript loop instance.

result should like:

states: [     state{         name: "name1"         when: somevar === onevar          //stuff     },     state{         name: "name2"         when: somevar === anothervar          //stuff     } ] 

but want start arbitrary javascript array, like

var mystatesobj = [{     "name": "name1"     "condition": onevar },{     "name": "name2"     "condition": anothervar }] 

and use loop create states qml object.

is possible?

i did tests , don't think can dynamically modify states list (seems it's object , no array internally)!?

here tests: create dynamic state (that work component template)

component {     id: statetemplate     state {} }  // use code create state object var st = statetemplate.createobject(parent, { name: "testsate", when: yourcondition }) 

try add state

states.push(st) // error because "states" not array!? states[states.length] = st // no error stages object didn't change @ all? 

you can iterate though existing states , everything, seems states object not changeable or missing here?


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -