Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide an item (delegate) inside a ListView QML

Tags:

qt

qml

Is there a way to hide a particular item on some event in a ListView?

So far I can do it by setting visible to false and height to zero of a delegate.

But If i have spacing in a listView set to 2 for example it appears that this solution is broken.

enter image description here

like image 863
Mikhail Avatar asked Feb 01 '18 14:02

Mikhail


Video Answer


1 Answers

I think the proper way is to use a proxy model that filters out the elements that should not be displayed. You can use a QSortFilterProxyModel or implement your own QAbstractProxyModel. With that it is even possible to animate the removal and addition of the elements.

Or use SortFilterProxyModel if you don't wanna touch C++ and performance is not a problem

like image 87
Ben Avatar answered Sep 21 '22 14:09

Ben