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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
New Developer
georg
Posts: 65
Registered: ‎01-23-2009
My Carrier: O2

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.

 

Please use plain text.
Developer
simon_hain
Posts: 13,754
Registered: ‎07-29-2008
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
Please use plain text.
New Developer
georg
Posts: 65
Registered: ‎01-23-2009
My Carrier: O2

Re: Access components in attached objects

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

Please use plain text.
Developer
bbdevguy
Posts: 75
Registered: ‎11-19-2008

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.

Please use plain text.