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

[Regression] DragHandler active property does not change when used in a Button

    XMLWordPrintable

Details

    • Linux/X11

    Description

      When a DragHandler is used inside a Button, its active property does not change when dragging starts.

      In the example qml code below, the steelblue Rectangle cannot be dragged from the Button because the active property of the DragHandler does not change. If the Button is replaced with a Rectangle, everything works as expected.

      Regression: worked with Qt 5.15.2

      import QtQuick 2.15
      import QtQuick.Window 2.0
      import QtQuick.Controls 2.15
      
      Window {
          id: window
          width: 1000
          height: 1000
          visible: true
      
          Rectangle {
              id: area
              color: "lightgrey"
              anchors.centerIn: parent
              width: 900
              height: 900
      
              Rectangle {
                  width: 50
                  height: width
                  color: dragHandler.active ? "red" : "lightblue"
              }
      
              Button { // no problem if this is a Rectangle
                  width: 40
                  height: 40
                  anchors {left: parent.left; verticalCenter: parent.verticalCenter}
      
                  Rectangle {
                      id: icon
                      color: "steelblue"
                      width: parent.width / 2
                      height: width
                      Drag.active: dragHandler.active
                      Drag.hotSpot.x: dragHandler.centroid.pressPosition.x
                      Drag.hotSpot.y: dragHandler.centroid.pressPosition.y
                      states: [
                          State {
                              when: !icon.Drag.active
                              AnchorChanges {
                                  target: icon
                                  anchors.horizontalCenter: parent.horizontalCenter
                                  anchors.verticalCenter: parent.verticalCenter
                              }
                          }
                      ]
                  }
                  DragHandler {
                      id: dragHandler
                      target: icon
                  }
              }
          }
      
          DropArea {
              anchors.fill: area
          }
      }
      

      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
              maren Maren Kucza
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes