Search code examples
qtexpandablelistviewqlistview

qt : expandable/collapsable listview


I hope to create a "NEW" listview like QML Exmaple with native Qt classes.

Exactly I want to make a listview which works like below.

enter image description here enter image description here

It looks like a QML example but slightly differs. QListView has a limitation for it's layout, right? I want a hint for overcoming the problem.


Solution

  • You'd want to use GridView instead of ListView. That'll get you a step closer to making your UI look like what you have designed. However currently Qt Quick only supports fixed cell sizes of grid items, which means you won't be able to expand the cell size of just one item. All you can do is set up the cell size to fit the expanded item so that every grid item will take up as much space as it could possibly need. Then you can alter the dimensions of each item without worrying about fitting issues.