Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-35995

Clicked signal not emitted on MouseArea when changing visibility and listening for doubleClicked

    XMLWordPrintable

Details

    • 089c3b15b9 (qt/qtdeclarative/dev) 089c3b15b9 (qt/tqtc-qtdeclarative/dev) d4021a8d62 (qt/tqtc-qtdeclarative/5.15) 11ce4362e7 (qt/qtdeclarative/6.3) 11ce4362e7 (qt/tqtc-qtdeclarative/6.3)

    Description

      Hi,

      There's an issue with the clicked signal of a MouseArea when changing its visibility (or any other parent component) and listening for doubleClicked signal too.

      Suppose that we have a chatroom list. When we click on a room we show its users and when we double-click we enter it, hiding the chatroom list and entering the selected chatroom. If we leave the room we go back to the chatroom list, making it visible again. If we now single-click one room its users won't show as expected because the onClicked signal won't be emitted.

      Here's some simple code that shows the issue:

      import QtQuick 2.0
      
      Item {
          width: 360
          height: 360
      
          MouseArea {
              anchors.fill: parent
              onClicked: {
                  console.log("clicked")
              }
              onDoubleClicked: {
                  console.log("double-clicked")
      /* Uncomment this to reproduce
                  visible = false
                  visible = true
      */
              }
          }
      }
      

      If we double-click and then single-click the window, the log will show "clicked", "double-clicked" and "clicked". If we uncomment the lines at onDoubleClicked and do the same, the log will show "clicked" and "double-clicked", missing the last click. If we then wait a bit and click again, the clicked signal is emitted normally.

      This happens most of the time, but not always. You may have to try it a couple of times to reproduce it. Note that it only seems to happen when listening for both clicked and doubleClicked events, if listening for just one of them it works fine.

      Also if we use onPressed instead of onClicked the issue persists, but I haven't tried with other signals.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              srutledg Shawn Rutledge
              devenor Devenor
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews