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
alecaserez
Posts: 18
Registered: ‎08-26-2012
My Device: Z10
Accepted Solution

qml page call (navigationpane) from c + +

This is not working for me

 

ApplicationUI::ApplicationUI(bb::cascades::Application *app)
: QObject(app)
{
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    qml->setContextProperty("_melibeta", this);

    AbstractPane *root = qml->createRootObject<AbstractPane>();
    app->setScene(root);
}

 

Function

 

void ApplicationUI::showPhotoInCard()
{
	QmlDocument *qml = QmlDocument::create("asset:///DetailsPage.qml").parent(this);
    Page *detailspage = qml->createRootObject<Page>();

	app->push(detailspage);
}

 HELP!

Please use plain text.
Developer
simon_hain
Posts: 16,216
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: qml page call (navigationpane) from c + +

the push method is a function of navigationPane.
The easiest approach would be to give your navigationPane an objectName and use findChild to access it.

As some ui things are easier done in qml we also use signals sometimes to connect the c++ part to qml, like a "showDialog" signal.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
alecaserez
Posts: 18
Registered: ‎08-26-2012
My Device: Z10

Re: qml page call (navigationpane) from c + +

I do not understand your point. I declare my page qml and sent him the push.
My problem is the need to use a page QML from C + +

Please use plain text.
Developer
simon_hain
Posts: 16,216
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: qml page call (navigationpane) from c + +

this should resolve your question:
https://developer.blackberry.com/cascades/documentation/dev/integrating_cpp_qml/
especially the "Accessing child objects" paragraph.

you use findChild to find the navigationPane and call the push method on it.
Currently you try to call it on the app object which does not have the method.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
alecaserez
Posts: 18
Registered: ‎08-26-2012
My Device: Z10

Re: qml page call (navigationpane) from c + +

ok. then

 

I have not the sdk here

 

ApplicationUI::ApplicationUI(bb::cascades::Application *app)
: QObject(app)
{
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("_melibeta", this);
    AbstractPane *root = qml->createRootObject<AbstractPane>();
 
    QmlDocument *qmlother = QmlDocument::create("asset:///DetailsPage.qml").parent(this);
    Page *detailspage = qmlother->createRootObject<Page>();
 
    app->setScene(root);
}
 
void ApplicationUI::showPhotoInCard()
{
NavigationPane *puntero = root->findChild<NavigationPane*>(navpane);
navpane->push(detailspage);
}
-- ---------------------------
main.qml
 
NavigationPane{
ObjectName: "navpane"
 
Page{
 
}
}
 
-- ---------------------------

 

Please use plain text.