Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 247
Registered: ‎11-22-2011
My Device: Blackberry Playbook
Accepted Solution

Address component with string syntax in QML

Hello,

 

i would like to loop over about 50 components created manually in qml. They have ids like "comp1", "comp2", "comp3" and so on. So i thought i could use the following syntax inside the loop

 

["comp" + i].property

 

to address a components property, but it doesnt work. 

 

Its strange because this kind of syntax works when accessing properties in qml:

 

console.log(main.testProperty)  and

console.log(main["testProperty"]) is the same and works

 

Any idea?

 

P.S. i know that i can do it  with c++, but my goal is to do the view-related things in the qml-layer an i am just exploring how far i can go...

 

 

Developer
Posts: 247
Registered: ‎11-22-2011
My Device: Blackberry Playbook

Re: Address component with string syntax in QML

Ok, its not possible, but i just found another way to get the child components of a container:

container.controls gives an array of all children. Now i can easily loop with myContainer.controls[i] through all children of the container an set properties.

Very handy.