I have a ListView table. I want to add some filter buttons to hide/show items of this table based on item type. The easiest way is set visible property of the item delegate. However, hidden items are still counted in listView.contentHeight, or listView.visibleArea.heightRatio. As a result, these values change when scrolling and affect the height and position of the scrollbar, it collapses, expands, jumps in no order.
Other issue is that in the listView, if an item is selected, there is no way to know its index, for instance it looks like it is in the second place in the table but actually its index is higher because of the invisible items. It could be nice if the invisible items are not counted at all.
Please help how to solve this issue. Thank you all.
ListView{
id: listView
delegate: itemdelegate
}
Component{
id: itemdelegate
Item{
visible: model.type === filteredType ? true: false
}
}
Append items to your display model dynamically, f.e.
filterButton.onClicked:{
for(var i = 0; i < myListModel.count;i++)
{
if(myListModel.get(i).desiredProperty == "desiredValue")
myDisplayModel.append("prop1":"val1");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With