앱 시작 후 팝업 대화 상자를 표시하는 방법은 무엇입니까?

앱 시작 후 팝업 대화 상자를 표시하는 방법은 무엇입니까?

모든 항목의 속성 PopupUtils.open()에서 명령을 사용하면 아무 작업도 수행되지 않습니다. 예:Component.onCompleted

Rectangle {
    id: rect
    height: 600
    width: height
    Component.onCompleted: {
        PopupUtils.open(dialog, rect)
        }

    Component {
         id: dialog
         Dialog {
             id: dialogue
             title: "Save file"
             text: "Are you sure that you want to save this file?"
             Button {
                 text: "cancel"
                 onClicked: PopupUtils.close(dialogue)
             }
             Button {
                 text: "overwrite previous version"
                 color: "orange"
                 onClicked: PopupUtils.close(dialogue)
             }
             Button {
                 text: "save a copy"
                 color: "orange"
                 onClicked: PopupUtils.close(dialogue)
             }
         }
    }

앱이 시작된 직후 팝업 대화 상자를 올바르게 표시하려면 어떻게 해야 합니까?

답변1

PopupUtils.Open(dialog, id)은 버튼 작업을 위한 것입니다.

따라서 visible 속성이 false인 버튼을 추가하고 위의 "id" 대신 해당 숨겨진 버튼의 ID를 전달합니다(물론 인용 없이).

원천:

같은 문제가있었습니다 :)

답변2

어떤 이유로 Timer든 다음을 사용하여 작동합니다.

Rectangle {
    id: rect
    height: 600
    width: height
    Component.onCompleted: {
        start_timer.start()
     }

    Timer {
        id: start_timer
        interval: 200;
        onTriggered: PopupUtils.open(dialog, rect)
    }

    Component {
         id: dialog
         Dialog {
             id: dialogue
             title: "Save file"
             text: "Are you sure that you want to save this file?"
             Button {
                 text: "cancel"
                 onClicked: PopupUtils.close(dialogue)
             }
             Button {
                 text: "overwrite previous version"
                 color: "orange"
                 onClicked: PopupUtils.close(dialogue)
             }
             Button {
                 text: "save a copy"
                 color: "orange"
                 onClicked: PopupUtils.close(dialogue)
             }
         }
    }

관련 정보