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: 237
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha
My Carrier: Telkomsel

How to access custom QML root from .cpp ?

Hi, I make page in a custom QML file and also .cpp file to control it

 

ex: detailPage.qml and detailPage.cpp

 

how to access root of detailPage.qml from detailPage.cpp ?

 

I already try using this :

on detailPage constructor :

 

QmlDocument *qml = QmlDocument::create("asset:///detailPage.qml").parent(this);
    AbstractPane *root = qml->createRootObject<AbstractPane>();
 
but cannot access qml component from root
 
How to do this?
 
Thanks

 

Developer
Posts: 1,657
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: How to access custom QML root from .cpp ?

your qml object needs a

objectName: "theName"

 

and from C++ you can get it this way:

 

Application::instance()->scene()->findChild<Type of your Control>("theName")

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner