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

ListView.snapMode doesn't work correctly if ListView.spacing is different from 0.

    XMLWordPrintable

Details

    Description

      ListView {
          id: list
          clip: true
          model: 20
          width: 200
          height: 400
          spacing: 20
          snapMode: ListView.SnapToItem
          delegate: Rectangle {
              width: 200
              height: 100
              border.color: "blue"
              Text {
                  anchors.centerIn: parent
                  font.pixelSize: 25
                  text: index
              }
          }
      }
      
      Button {
          font.pixelSize: 20
          text: list.contentY.toFixed(0)
          onClicked: {
              list.returnToBounds()
          }
      }
      

      Scroll the list so that the contentY is between 50 (delegate.height / 2) and 70 (delegate.height / 2 + list.spacing) (Similarly for other elements.)
      Expected result: The ListView settles with second item aligned with the start of the ListView.
      Observed result: Nothing happens. (Calling returnToBounds() also does nothing.)

      Attachments

        Activity

          People

            johanhelsing Johan Helsing
            evgeny_kolchin Evgeny Kolchin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: