Dialog triggers onVisibleChange slot twice



  • I do not understand why Dialog.onVisibleChange slot is triggered twice for opening and for closing the dialog. I doubt it is a bug but rather my shallow understanding.

        Dialog {
            id: dialog
            onVisibleChanged: {
                console.log(" ***** m visible***** visible", visible);
            }
            onAccepted: close();
        }
    
        Connections {
            target: dialog
            onVisibleChanged: {
                console.log(" ***** m from connections visible ***** visible", dialog.visible);
            }
            onVisibilityChanged:
            {
                console.log(" ***** m from connections visibility ***** visible", dialog.visible);
            }
        }
    

    The result is:

    qml:  ***** m visible***** visible true
    qml:  ***** m from connections visibility ***** visible true
    qml:  ***** m visible***** visible true
    qml:  ***** m from connections visibility ***** visible true
    qml:  ***** m visible***** visible false
    qml:  ***** m from connections visibility ***** visible false
    qml:  ***** m visible***** visible false
    qml:  ***** m from connections visibility ***** visible false
    

    I expected the slot to be executed once with true and once with false, not twice for both. On the other side, I expected other slot from the Connections to be triggered (and again once, not twice for false and true).

    For MessageDialogs in some cases also twice and in other just once.
    Note: Qt 5.7 is used.


  • Moderators

    Hi! Maybe you can provide a minimal example so we can try to reproduce it.



  • @AleksM

    A note of similar behaviour found in this topic, but without explanation.


Log in to reply
 

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