¿Cómo mostrar un cuadro de diálogo emergente después de iniciar la aplicación?

¿Cómo mostrar un cuadro de diálogo emergente después de iniciar la aplicación?

Si uso el PopupUtils.open()comando en la Component.onCompletedpropiedad de cualquier elemento, no hace nada, ejemplo:

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

¿Cómo puedo mostrar correctamente un cuadro de diálogo emergente justo después de que se haya iniciado la aplicación?

Respuesta1

PopupUtils.Open(dialog, id) está destinado a funcionar con botones.

Por lo tanto, agregue un botón con la propiedad visible como falsa y pase la identificación de ese botón oculto en lugar de "id" arriba (sin comillas, por supuesto).

Fuente:

Tuve el mismo problema :)

Respuesta2

Por alguna razón, funciona usando a Timer, es decir:

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

información relacionada