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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
New Developer
Posts: 92
Registered: ‎01-23-2009
My Device: Z10
My Carrier: klarmobil

Access components in attached objects

I have a dialog as attached object in my page. My interaction with it is just my_dialog.open() on some events but I'm asking me if it would be possible to access its components (in this case some text fields) to modify their content.

 

The dialog has a structure like:

Dialog{

  Container {

    Container {

       TextField {
          id: text_field_one

 

something like my_dialog.text_field_one.text = ... however does not work.

 

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Access components in attached objects

if you access it in the same qml you should be able to modify the textfield by its id only, like "text_field_one.text ="
otherwise you should define a property for it.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 92
Registered: ‎01-23-2009
My Device: Z10
My Carrier: klarmobil

Re: Access components in attached objects

My dialog does indeed reside in a separate file. How do I defina a property for it?

Developer
Posts: 121
Registered: ‎11-19-2008
My Device: Not Specified

Re: Access components in attached objects

You can do that via the objectName property.

 

attachedObjects:[

Dialog{

  objectName: "mydialog"

  Container {

    Container {

       TextField {
          id: text_field_one

          objectName:"mytextfield"

...

 

Then from C++ use

 

Dialog* mydialog = root->findChild<Dialog*>("mydialog");
TextField* mytextfield = mydialog->findChild<TextField*>("mytextfield");

 

 

This also works for attached object defined in their own QML file.