Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Dialog triggers onVisibleChange slot twice

Dialog triggers onVisibleChange slot twice

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AleksM
    wrote on last edited by AleksM
    #1

    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.

    A 1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

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

      1 Reply Last reply
      1
      • A AleksM

        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.

        A Offline
        A Offline
        AleksM
        wrote on last edited by
        #3

        @AleksM

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved