Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QML ListView with variable Item heights
QtWS25 Last Chance

QML ListView with variable Item heights

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 2.1k 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.
  • D Offline
    D Offline
    Dev1337
    wrote on last edited by Dev1337
    #1

    Hi there,

    so i am trying to build a ListView like the Facebook timeline.
    The Items in the ListView should have a variable Item height.

    Is there a way to do this?
    Right now i am using a Column with an Repeater inside but this got a huge performace problem to show more than 50 Objects. ( it gets choppy/slow @ scrolling)

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi! You need to define your own delegate. See http://doc.qt.io/qt-5/qml-qtquick-listview.html#delegate-prop

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dev1337
        wrote on last edited by
        #3

        My delegate looks like this :

        Item {
        height: text.height + 40px
        Width: 400px

        Text {
        id: text
        Width: parent.Width
        anchors.verticalCenter:parent.verticalCenter
        text: "some random text, but the text can have up to 10 rows so the height is not fix"
        }
        }

        So the ListView can handle Items with a variable height? I thought the ListView needs items with fixed Heights? Or am I wrong?

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @Dev1337 said:

          So the ListView can handle Items with a variable height?

          Yes, no problem. Take a look at this image: https://drive.google.com/file/d/0B2D1UtsPfTx-aGR4TmxVLWNUX3M/view?usp=sharing. On the left side is a ListView. It has items with a small hight (the ones with black background) and items with variable hight depending on the amount of text they contain. (In this image these text items all have the same hight only because they all contain the same dummy text.)

          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