How to know dialog box is destroyed for emitting a signal to calling page to load Page2.qml automatically



  • I've a main.qml where 3 states are maintained

    while in stateA (start up state) a dialog box qml is displayed (Ref: http://qt-project.org/forums/viewthread/26455)

    on destroying the shown dialog box, i wish to send a signal to my main.qml to load Page2.qml automatically.

    i tried doing this, the signal is emited before destroying the dialog box and disturbing complete functionality.



  • Nice to see that my example is helping.

    Calling the destroy method, will not directly destroy the object. So in your case emitting the signal at that moment is to early.

    Each QML Component has an attached property called onCompleted and its counterpart onDestruction which is called when the destruction of the component begins (still it is not gone yet but it comes close).

    @
    MyDialogComponent {
    id: myDialog
    ...
    signal destroyBegins
    Component.onDestruction: myDialog.destroyBegins()
    ...
    }
    @



  • Thanks for your reply. One more issue please...I want to display my Dialog.qml dynamically when a state is changed using Loader. Below is my code.

    Loader {
    id: cmpntLoader
    Component{
    id: dialogComponent
    var component = Qt.createComponent("Popup.qml");
    if (component.status === Component.Ready)
    {
    component.createObject(main, {"slot":slotNum});
    }

        onDialogClosed: {
    

    main.state = "nextStep"
    do something more.....
    }
    }
    }

    states: [
    State {
    name: "Slot"
    PropertyChanges {
    target: cmpntLoader; sourceComponent: dialogComponent;
    }
    ........
    }
    ]

    I'm unable to get the above loading component and handling the emitted signals. Thus, using
    Quote: Qt.createComponent("BrandPopup.qml").component.createObject(main, {"slot":slotNum}) Unquote
    on click of a button in main.qml as a temporary measure.



  • I'm missing big parts of your code. Next time please place your code between at-sign characters (most right icon on the top)

    I do not quite understand what your trying to do, but as far as I know putting JavaScript code in the component does not work. You may put them in the attached property Component.onCompleted.

    @
    Loader {
    id: cmpntLoader
    Component{
    id: dialogComponent
    property int slotNum // I expect you have something like this too
    Component.onCompleted: {
    var component = Qt.createComponent("BrandPopup.qml");
    if (component.status === Component.Ready) {
    component.createObject(main, {"slot":slotNum});
    }
    }
    }
    @

    Maybe it would help if you give a more complete example of your code to show what you try to do.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.