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

Native Development

Reply
Developer
neilhogg69
Posts: 34
Registered: ‎05-11-2012
My Carrier: Vodacom
Accepted Solution

Reference ID's from different qml files

I have 2 qml files. One containing a tabbed pane (tabbedMenu.qml) and the other (ContentContainer.qml) with a container containing a label.

I use the ContentContainer.qml as a template for the tabbedPane pages like so :
 

(ContentContainer.qml)
Contains a label with id headerLabel

 


(tabbedMenu.qml) 

TabbedPane {
     Page {
          id: connectTab
          paneProperties: TabbedPaneProperties {
               title: "Tab"
          }

          content: ContentContainer {  
               id: connectContent
               Label {
                    id: testLabelID
                    text: "Text"
               }
         }
     }
...

Is there a way to update headerLabel's value from tabbedMenu.qml when a tab is changed?
 

Please use plain text.
Developer
neilhogg69
Posts: 34
Registered: ‎05-11-2012
My Carrier: Vodacom

Re: Reference ID's from different qml files

I figured it out. I just used a C++ class, registered it as a property and used the class variables to manipulate the variables on the QML side. 

 

See https://bdsc.webapps.blackberry.com/cascades/documentation/ui/integrating_cpp_qml/index.html for an example

Please use plain text.
Developer
peter9477
Posts: 5,631
Registered: ‎12-08-2010
My Carrier: none

Re: Reference ID's from different qml files

This sounds like a case where you could "bind" a property to the parent container, something like putting "property string myLabel: headerLabel.value" (not exact code) in the ContentContainer. Then you can reference it from other file using "connectContent.myLabel".

I think the section on "Accessing a component's properties" in https://bdsc.webapps.blackberry.com/cascades/documentation/ui/custom_components/index.html describes this...

Any help?

Peter Hansen -- (PlayBook and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
neilhogg69
Posts: 34
Registered: ‎05-11-2012
My Carrier: Vodacom

Re: Reference ID's from different qml files

Thanks for the reply. This definitely sounds like another good solution to the problem i was having. I will try this! 

Please use plain text.