09-21-2012 07:18 AM
Hi ,
i want to add controls dynamically to container . but when i call Q_INVOKABLE method with name getLikesList() from qml my application crashe. If i call method from button click it's working but call method from onCreationCompleted crash application. i want to call method automatically not on button click event.
anyone know where should i write app.getLikesList() statement.
My qml
import bb.cascades 1.0
Page {
content: Container {
objectName: "containerLikes"
Button {
text: "Button"
onClicked: {
//app.getLikesList()
}
}
}
onCreationCompleted: {
app.getLikesList()
}
}
Cpp
void App::getLikesList() {
// find method can not find containerLikes object when call from onCreationCompleted
Container *container = root->findChild<Container*>("containerLikes");
activityIndicator = ActivityIndicator::create();
activityIndicator->start();
container->add(activityIndicator);
}
is any way to dynamically add controls from qml file ?
Thank You
09-21-2012 10:11 AM
Hi raj_jyani,
Hope it helps.
09-24-2012 12:46 AM
Hi amarcon,
Thank you for your reply, but my problem is
Container *container = root->findChild<Container*>("containerLikes");
cannot find container object from qml when i used
onCreationCompleted: {
app.getLikesList()
}
if i call app.getLikesList() from button click event then it completely working .
is any statement like we use in java invokeLater() ?
09-24-2012 01:05 AM
Hi raj_jyani,
We are also adding dynamic controls to my Page. You can have two approaches here -
1.) Either, add Like List to your existing page, and keep it invisible, and at runtime when you want to show it, make it visible.
2.) Make a separate custom component for your Like List (QML Document- say it as LikeList.qml). Now, at runtime, add it to your page as amarcon suggested.
void App::addLikeLits() {
QmlDocument *qml = QmlDocument::create().load("LikeList.qml");
if (!qml->hasErrors()) {
Container *control= qml->createRootNode<Container>();
if (control) {
myContainer->add(control);
}
}
}
I am using both approaches in my app, and duo are working fine.
09-24-2012 02:38 AM
Hi Kanak.
Thank you for your reply, i understand your point .
i m getting data from web server so count is not predefined that's why i not apply visibility concept.
i think you did not mark my problem . my adding data code completely working but only on button click event.
i want to call it automatilly when page is complete render. so i called method from onCreationCompleted:
but it's not working .
i can add control from onClick event but not from onCreationCompleted:
Thank You
09-26-2012 04:58 PM
Hi raj_jyani,
now with R9, did you have a chance to take a look at this?
https://developer.blackberry.com/cascades/document
Cheers,