1

当用户单击应用程序图标时,我想显示一个启动页面。为此,我创建了工作表并附加到页面。 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++ 方法中关闭工作表?

4

1 回答 1

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
于 2013-08-06T13:24:04.713 回答