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

Tumbler: displacement calculation goes wrong if wrap is disabled and tumbler gets resized

    XMLWordPrintable

Details

    • d39a6d80f63414a4e933ac2f859805635850942a (qt/qtquickcontrols2/5.13) 9d9ba61a7503047e8417a52e3799f51e76067df8 (qt/qtquickcontrols2/5.12)

    Description

      In attached example, label is showing the displacement value for the delegate and it seems to jump into odd values when the window is vertically resized. The reference point for displacement calculation seems to move around.

      import QtQuick 2.10
      import QtQuick.Window 2.10
      import QtQuick.Controls 2.3
      
      Window {
          id: window
          width: 520
          height: 440
          visible: true
          title: "contentY: " + view.contentY.toFixed(2)
              + ", originY: " + view.originY.toFixed(2)
              + ", height: " + view.height.toFixed(2)
              + ", contentHeight: " + view.contentHeight.toFixed(2)
              + ", delegateHeight: " + (tumbler.height / tumbler.visibleItemCount).toFixed(2)
      
          property Item view: tumbler.contentItem.children[0]
      
          Tumbler {
              id: tumbler
              model: 30
              currentIndex: 15
              width: 200
              height: parent.height
              wrap: false
              visibleItemCount: 7
      
              delegate: Text {
                  text: "index = " + index + ", displacement = " + Tumbler.displacement.toFixed(2)
                  color: "black"
                  opacity: tumbler.currendIndex === index ? 1.0 : 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6
                  leftPadding: 12
                  verticalAlignment: Text.AlignVCenter
      
                  Rectangle {
                      anchors.fill: parent
                      color: "transparent"
                      border.color: "black"
                  }
              }
          }
      
          Rectangle {
              anchors.right: parent.right
              anchors.rightMargin: label.height
              width: 1
              height: tumbler.height / 2 - (tumbler.height / tumbler.visibleItemCount / 2)
              color: "black"
      
              Rectangle {
                  anchors.bottom: parent.bottom
                  anchors.horizontalCenter: parent.horizontalCenter
                  width: 5
                  height: 1
                  color: "black"
              }
          }
          Text {
              id: label
              text: "preferredHighlightBegin/End"
              anchors.left: parent.right
              rotation: 90
              transformOrigin: Item.TopLeft
          }
          Rectangle {
              anchors.right: parent.right
              anchors.rightMargin: label.height
              y: tumbler.height / 2 + (tumbler.height / tumbler.visibleItemCount / 2)
              width: 1
              height: tumbler.height - y
              color: "black"
      
              Rectangle {
                  anchors.horizontalCenter: parent.horizontalCenter
                  width: 5
                  height: 1
                  color: "black"
              }
          }
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              mitch_curtis Mitch Curtis
              poikelin Joni Poikelin
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes