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: 214
Registered: ‎03-18-2012
My Device: 8520
My Carrier: Company
Accepted Solution

How point the QML components in C++?

[ Edited ]



I  have the below  QML and C++ code and i want to point the QML container component  in  C++ ,

but  the C++ code i write is not working for the container component having id = container. please suggest where is the problem?


      id: container
      layout: StackLayout
        orientation: LayoutOrientation.TopToBottom
       id: submit
       text: "Submit" 


C++ Code


QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

// create root object for the UI
Page *root = qml->createRootObject<Page>();
QObject *container = root->findChild<QObject*>("container");



Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: How point the QML components in C++?

The ID is how you refer to it in QML. objectName is the property you need to refer to it in C++.


See https://developer.blackberry.com/cascades/documentation/dev/integrating_cpp_qml/

Paul Bernhardt
Application Development Consultant

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker