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

ListView erroneous behavior when ListModel is initially empty

    XMLWordPrintable

Details

    • bd2eece4a68808c771d39cd53922ef538d0ba54d

    Description

      Run the code below. Note how the text change color from white to
      black when flicked, and the text snaps to the center of the white
      rectangle when the flicking ends.

      Now comment out this

       ListElement { text: "1969" } 


      line from the example and run the code again. Note how the text is
      now always white (and thus invisible when not moving). This seems
      to be because the ListView.StrictlyEnforceRange is failing, resulting
      in the ListView.isCurrentItem always returning false (change the text
      color to always be black to see that it doesn't snap to the center).

      import QtQuick 2.0
      Rectangle {
          ...
          ListModel {
              id: yearModel
              //ListElement { text: "1969" }
              Component.onCompleted: { for(var i = 0; i < 60; i++) append({"text": i+1970}) }
          }
          ...
      }
      

      Attachments

        1. main.qml
          0.6 kB
        2. Tumbler.qml
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bealam Bea Lam (closed Nokia identity) (Inactive)
            mathiasm Mathias Malmqvist
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes