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
New Contributor
Posts: 8
Registered: ‎03-26-2013
My Device: Z10 LE
My Carrier: Vodafone

AbstractPane in header

 I need to access the qml root element (which is an AbstractPane) from diferent functions in the code. I know a way to do so if it would be a Page, but I can't get it to work with an AbstractPane.

 

For a page:

header

 

namespace bb
{
    namespace cascades
    {
        class Page;
    }
}
...
Page *mAppPage;

 

c

 

mAppPage = qml->createRootObject<Page>();

 

What I need:

header

 

namespace bb
{
    namespace cascades
    {
        ???
    }
}
...
AbstractPane *mAppPage;

 

c

 

mAppPage = qml->createRootObject<AbstractPane>();

 

 

Does anyone know a solution for that?

Developer
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10
My Carrier: -

Re: AbstractPane in header

Look into this page. Your code is spot on, I don't see what the problem is...

 

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

AbstractPane *root = qml->createRootObject<AbstractPane>();
root->setProperty("labelText", "New text");
QObject *newButton = root->findChild<QObject*>("button");
newButton->setProperty("text", "Some text")
app.setScene(root);

 

----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!