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
Highlighted
Developer
Posts: 144
Registered: ‎12-18-2010
My Device: Limited Edition Z10 & Blackberry Playbook
My Carrier: Rogers Wireless
Accepted Solution

Accessing context property of main.qml from a custom list item in a seperate qml file

Hi all,

 

Sorry if this is already covered somewhere.

 

I currently have an app with a list view in my main.qml.  I have set a context property for my app class from c++ to be "app" in my main.qml.  My list is using a custom list item that is defined in a seperate qml file.  The custom list item has a context menu.  In this context menu I want to call Q_INVOKABLE functions that are part of my main app class in C++.  What is the best way to be able to do this?  Should I just set the context property on my custom list item qml file like I do with my main.qml or is there a better way?

 

Thanks

Playbook Apps:
Touch Painter, LinkShrink

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

Re: Accessing context property of main.qml from a custom list item in a seperate qml file

i think this has been covered a few times, but as it is not really intuitive:
a listitemcomponent resides in a different context, it cannot access the context property of the qml file.
you can use the reference to the listview to reach outside, see https://developer.blackberry.com/cascades/reference/bb__cascades__listview.html section ListItem.view
----------------------------------------------------------
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
Developer
Posts: 144
Registered: ‎12-18-2010
My Device: Limited Edition Z10 & Blackberry Playbook
My Carrier: Rogers Wireless

Re: Accessing context property of main.qml from a custom list item in a seperate qml file

Thanks Simon.

Playbook Apps:
Touch Painter, LinkShrink

BB10 Apps:
NoteToSelf , LinkShrink