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

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?


Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
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 native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner