Как закрыть лист в qml?

Я хочу показать заставку, когда пользователь нажимает на значок приложения. Для этого я создал лист и приложил к странице.
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

После завершения работы хочу закрыть ведомость. Поэтому я вызвал метод close (). Но лист не был закрыт.

Как закрыть лист в методе oncreationCompleted () или из любого метода c ++?

1

Решение

Вы пытаетесь закрыть Sheet до его открытия (анимация все еще выполняется), поэтому запрос на закрытие игнорируется. Вы должны следить за окончанием анимации (opened() сигнал), чтобы знать, если ваш Sheet открыт еще. Я бы сделал что-то подобное:

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
1

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]