10-04-2012 05:10 AM
Hello
I am developing one project.
In which main page is the Navigationpane, i.e I had loded in the application scene.
Now on the click of button the page is pushed to navigation pane.
2nd page qml
Page {
// page with a picture detail
id: pgImage
objectName: "pgImage"
actions: [
// create navigation panel actions here
ActionItem {
title: qsTr("Break")
onTriggered: {
imgView.imageSource = "asset:///images/picture1br.png"
}
}
]
attachedObjects: [
Custom_dialog {
id:custom_dialog
}
]
paneProperties: NavigationPaneProperties {
backButton: ActionItem {
onTriggered: {
// define what happens when back button is pressed here
// in this case is closed the detail page
navigationPane.pop()
}
}
}
Container {
id: cnImage
objectName: "cnImage"
background: Color.Black
Label {
text: qsTr("Page 2")
horizontalAlignment: HorizontalAlignment.Center
textStyle {
base: SystemDefaults.TextStyles.TitleText
color: Color.Yellow
}
}
ImageView {
id: imgView
imageSource: "asset:///images/picture1.png"
horizontalAlignment: HorizontalAlignment.Center
}
Label {
text: qsTr("Picture description")
horizontalAlignment: HorizontalAlignment.Center
}
Button {
text: "button"
onClicked: {
custom_dialog.open();
}
}
}
}
// Custom_dialog.qml
import bb.cascades 1.0
Dialog {
id: custom_dialog
objectName: "custom_dialog"
Container {
background: Color.Black
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
id: cnCustomDialog
layout: StackLayout {
orientation: LayoutOrientation.TopToBottom
}
objectName: "cnCustomDialog"
CheckBox {
id: chk
objectName: "chk_first"
text: "checked"
}
}
onOpenedChanged: {
if (opened) {
navigation.addcomponentTocutomDialog();
} else {
}
}
}
//
when dialog is open I am adding some component dynamically.
// function to add the componenet is also called and componenet are added. but It's not visible on the page.
void App::addcomponentTocutomDialog() {
qDebug() << "Display dialog";
Dialog *pagedetail = root->findChild<Dialog *>("custom_dialog");
if (pagedetail) {
qDebug() << "page found";
Container *container = pagedetail->findChild<Container *>(
"cnCustomDialog");
if (container) {
qDebug() << "container found";
Label *lbl_demo = Label::create().text(
"Demo label created on dialog");
container->add(lbl_demo);
}
}
}
Let me know what am I missing.
thanks in advance.
bskania.
10-04-2012 05:45 AM
root->findChild takes object name as parameter.
Set objectName property of your custom component
Custom_dialog {
id:custom_dialog
objectName: "custom_dialog"
}
Hope it helps.
Regards,
Nishant Shah
10-04-2012 06:02 AM