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

MouseArea pressed property change signal missing/wrong when propagating events

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.9.0
    • None
    • Ubuntu 16.04.1 on x86_64

    Description

      A MouseArea can either propagate events or have a correctly working onPressedChanged handler, but not both. Minimal example: a MouseArea fully covering a scrollable ListView, as in the following minimal (non-)working example:

      import QtQuick 2.6
      import QtQuick.Window 2.2
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          ListView {
              model: [Qt.rgba(1,0,0,0.5),"red","green","blue"]
              delegate: Rectangle {
                  height: 200
                  width:  parent.width
                  color:  modelData
              }
      
              anchors.fill: parent
          }
      
          MouseArea {
              anchors.fill: parent
      
              onPressed: {
                  mouse.accepted = false;
              }
              onReleased: {
                  mouse.accepted = false;
              }
              onPressedChanged: {
                  console.log("pressed changed to " + pressed);
              }
              propagateComposedEvents: true
          }
      }
      

      There's something odd going on with the notification for the pressed property: onPressedChanged only gets called when the button is pressed. Moreover in this situation, pressed evaluates to false in onPressedChanged, which is the reason why I am filing this as a bug.

      This happens regardless of "propagateComposedEvents". Only when "mouse.accepted=false;" is left out, does the pressed property get updated correctly (but then, of course, the ListView doesn't see the events at all, which isn't what I want).

      Attachments

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              komo KOMO Team
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes