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: 34
Registered: ‎05-11-2012
My Device: Bold 9900
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?
 

Developer
Posts: 34
Registered: ‎05-11-2012
My Device: Bold 9900
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

Highlighted
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
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 -- (BB10 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!
Developer
Posts: 34
Registered: ‎05-11-2012
My Device: Bold 9900
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!