Como exibir a caixa de diálogo pop-up após o início do aplicativo?

Como exibir a caixa de diálogo pop-up após o início do aplicativo?

Se eu usar o PopupUtils.open()comando na Component.onCompletedpropriedade de qualquer item ele não faz nada, exemplo:

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)
             }
         }
    }

como posso exibir corretamente uma caixa de diálogo pop-up logo após o aplicativo ser iniciado?

Responder1

PopupUtils.Open(dialog, id) destina-se a usar botões.

Portanto, adicione um botão com a propriedade visível como false e passe o id desse botão oculto no lugar do "id" acima (sem aspas, é claro).

Fonte:

Tive o mesmo problema :)

Responder2

Por alguma razão, funciona usando a Timer, ou seja:

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)
             }
         }
    }

informação relacionada