Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to show last delegates in ListView instead of first

How to show last delegates in ListView instead of first

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 3 Posters 369 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mihaill
    wrote on last edited by
    #1

    Hi!

    How to show last delegates in ListView instead of first?

    ODБOïO 1 Reply Last reply
    0
    • M Mihaill

      Hi!

      How to show last delegates in ListView instead of first?

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      hi @Mihaill

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.12
      
      
      ApplicationWindow {
          id: root
          width: 800
          height: 600
          visible: true
      
          property var _model : ["a","b","c","d","e","f"]  // _model.reverse()
      
          ListView {
              width: 180; height: 200
              id:l
              model:_model
              delegate: Text {
                  text: _model[ (_model.length-1) - index] //modelData
              }
          }
      }
      
      
      

      you can also reverse the model before setting

      1 Reply Last reply
      0
      • IntruderExcluderI Offline
        IntruderExcluderI Offline
        IntruderExcluder
        wrote on last edited by
        #3

        You can play with verticalLayoutDirection property of ListView. In your case it should be set to ListView.BottomToTop.

        1 Reply Last reply
        1
        • M Offline
          M Offline
          Mihaill
          wrote on last edited by
          #4

          I use:

          verticalLayoutDirection: ListView.BottomToTop
          

          but the start of the screen comes from the bottom (first) delegates of the model. I have to show the last delegates.

          1 Reply Last reply
          0
          • IntruderExcluderI Offline
            IntruderExcluderI Offline
            IntruderExcluder
            wrote on last edited by
            #5

            Or you can use positionViewAtEnd and positionViewAtIndex methods of ListView.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved