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

Setting ListView currentIndex doesn't set initial item correctly in certain circumstances

    XMLWordPrintable

Details

    Description

      In the following example, currentIndex is set to 50, but the resulting currentIndex is 0.

      import QtQuick 2.0
      import QtQuick.Window 2.0
      
      Window {
          id: window
          width: 400
          height: 400
          visible: true
      
          ListView {
              anchors.fill: parent
              highlightRangeMode: ListView.StrictlyEnforceRange
              preferredHighlightBegin: height / 3
              preferredHighlightEnd: height / 3 * 2
              currentIndex: 50
              model: 100
              delegate: Text {
                  id: delegateText
                  text: modelData
                  width: ListView.view.width
                  height: ListView.view.height / 3
                  font.bold: ListView.isCurrentItem
                  horizontalAlignment: Text.AlignHCenter
                  verticalAlignment: Text.AlignVCenter
                  font.pixelSize: 16
              }
          }
      }
      

      Attachments

        Issue Links

          Activity

            People

              oulu_hillbilly Sami Varanka
              net147 Jonathan Liu
              Votes:
              9 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: