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

How point the QML components in C++?

[ Edited ]

Hi,

 

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?

Page 

{
   Container
   {
      id: container
      layout: StackLayout
      {
        orientation: LayoutOrientation.TopToBottom
      }
     Button
     {
       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");

 

 

Please use plain text.
Retired
PBernhardt
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
BlackBerry
@PBernhardt

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