qml 程序退出确认对话框

来源:互联网 发布:windows thin 编辑:程序博客网 时间:2024/05/01 16:05
MessageDialog
    {
        id:myMsgbox
        standardButtons: StandardButton.Yes | StandardButton.No
        modality: Qt.ApplicationModal
        title: "确认退出"
        text:"你确定要退出商旅平台吗?"
        onYes:
        {
            Qt.quit();
        }
    }

    StackView {
        id: stackView
        anchors.fill: parent
        focus: true
        Keys.onReleased:{
            if (event.key === Qt.Key_Back )
            {
                console.log("key pressed");
                console.log("stackView.depth = "+stackView.depth);
                 if(stackView.depth > 1){
                             stackView.pop();
                             event.accepted = true;//消息不再往下传
                 }
                 else
                 {
                     myMsgbox.open();
                     event.accepted = true;//消息不再往下传
                 }
            }
        }

        initialItem: {
            Qt.resolvedUrl("qrc:///qml/UserInfo/QLogin.qml")
        }

}


转载:http://blog.163.com/wslngcjsdxdr@126/blog/static/1621962302014817101237288/

0 0
原创粉丝点击