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
ashish12169
Posts: 214
Registered: ‎03-18-2012
My Device: 8520
Accepted Solution

In Qml document how to identify the components..

Hi,

 

I  have a Qml document in which i have one label and button . on button's  click i want to change the text of the label but i donot know how to identify the  label in the button's onClick methode.

Please use plain text.
Developer
YamilBracho
Posts: 713
Registered: ‎05-31-2010
My Device: 8520

Re: In Qml document how to identify the components..

Just add the id property, say

Label {

  text: "My Label"

  id: lblMyLabel

}

 

Please use plain text.
Developer
ashish12169
Posts: 214
Registered: ‎03-18-2012
My Device: 8520

Re: In Qml document how to identify the components..

Hi,
can you specify what is syntax for the onclick methode
onClicked: {

}
Please use plain text.
Developer
YamilBracho
Posts: 713
Registered: ‎05-31-2010
My Device: 8520

Re: In Qml document how to identify the components..

as you wrote...:Yes:

Please use plain text.
Developer
ashish12169
Posts: 214
Registered: ‎03-18-2012
My Device: 8520

Re: In Qml document how to identify the components..

Hi,

right answer is
lblMyLabell.setText("AShish");
Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: In Qml document how to identify the components..

this will also work:
lblMyLabel.text = "your text"

it will call the setter (setText) internally.
";" at the end is optional.

Andrey Fidrya, @zmeyc on twitter
Please use plain text.