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

QML Slider offset between handle and mouse cursor

    XMLWordPrintable

Details

    Description

      Create a slider in an item and customize it like in the following code :

          Item {
              id: item1
              x: 0
              y: 0
              width: 200
              height: parent.height
      
              Rectangle {
                  id: background
                  anchors.fill: parent;
                  color:Qt.rgba(0.9,0.9,0.9,1);
              }
      
              Slider {
                  anchors.centerIn: parent
                  orientation: Qt.Vertical
                  height: parent.height
      
                  style: SliderStyle {
                      groove: Rectangle {
                          implicitWidth: 200
                          implicitHeight: 8
                          color: "gray"
                          radius: 8
                      }
                      handle: Rectangle {
                          anchors.centerIn: parent
                          color: control.pressed ? "white" : "lightgray"
                          border.color: "gray"
                          border.width: 2
                          width: 20
                          height: 20
                          radius: 6
                      }
                  }
              }
      
          }
      

      The problem appears when the size of the handle is changed to have it wider than high, so change in the handle :

          width: 20
          height: 80 //for example
      

      And then, when the handle is moved, it doesn't stay under the mouse cursor but there is an offset between the two. The greater the height of the handle is, the greater the offset is.

      This is even reproducible with Qt6.3.1 and 5.15.8

      Attachments

        Activity

          People

            vhilshei Volker Hilsheimer
            steveqtb SteveM
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: