I want to show a splash page when the user clicks on the application icon. For this I've created Sheet and attached to the page. main.qml
import bb.cascades 1.0
Page {
Container {
Label {
text: "Home page"
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
}
}
attachedObjects: [
Sheet {
id: mySheet
content: Page {
Label {
text: "Splash Page / Sheet."
}
}
}
]//end of attached objects
onCreationCompleted: {
//open the sheet
mySheet.open();
//After that doing some task here.
---------
---------
---------
//Now I'm closing the Sheet. But the Sheet was not closed.
//It is showing the Sheet/Splash Page only, not the Home Page
mySheet.close();
}
}//end of page
After completion of the work, I want to close the Sheet. So I've called the close () method.But the Sheet was not closed.
How do I close the sheet in oncreationCompleted() method or from any c++ method?
You are trying to close the Sheet
before it's opening is complete (the animation is still running), so the close request is ignored by it. You have to monitor the end of the animation ( opened()
signal) to know if your Sheet
is opened yet. I would do something like that:
import bb.cascades 1.0
Page {
Container {
Label {
text: "Home page"
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
}
}
attachedObjects: [
Sheet {
id: mySheet
property finished bool: false
content: Page {
Label {
text: "Splash Page / Sheet."
}
}
// We request a close if the task is finished once the opening is complete
onOpened: {
if (finished) {
close();
}
}
}
]//end of attached objects
onCreationCompleted: {
//open the sheet
mySheet.open();
//After that doing some task here.
---------
---------
---------
//Now I'm closing the Sheet. But the Sheet was not closed.
//It is showing the Sheet/Splash Page only, not the Home Page
mySheet.finished = true;
// If the Sheet is opened, we close it
if (mySheet.opened) {
mySheet.close();
}
}
}//end of page
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.