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

Support bottom-to-top flow in ListView

XMLWordPrintable

      The ListView content is sometimes laid out from bottom to top order, for example in Conversational messaging. Just reversing the items is not enough, as the initial position of the view, and the addition and the removal of items from the list view will still be behave in top-to-bottom directed way.

      So instead of having to write

      import QtQuick 1.0
      
      ListView {
          id: conversationList
          model: reversedModel
          // make sure view is positioned at the bottom of the view on startup
          Component.onCompleted: conversationList.positionViewAtIndex(model.count-1, ListView.Beginning);
      }
      Button {
          onClicked: {
              // add new message to conversation, last item is the latest
              conversationList.model.append( { "message": inputField.text, "contact": "Jake" } );
              // make sure the new conversation is visible
              conversationList.positionViewAtIndex(model.count-1, ListView.Beginning);
          }
      }
      

      it would nice to be able to write

      import QtQuick 1.0
      
      ListView {
          id: conversationList
          flow: ListView.BottomToTop
          model: myModel // no need to reverse order of data in the models for the presentation
      }
      
      Button {
          onClicked: {
              // add new message to conversation, first item is the latest
              myModel.insert(0, { "message": inputField.text, "contact": "Jake" } );
          }
      }
      

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

            bealam Bea Lam (closed Nokia identity) (Inactive)
            jpetrell Joona Petrell
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes