Solved Remove a ListElement from the ListView without removing it from the model
-
Hello,
I do have a list of component. That list is defined by a JS Model.
I would like to handle the visibilty of some elements without removing the elements from the model.I fact I do save some param via the index of the model and if I remove it it will make all my saving function obselete.
Here is an example of what if have :
property var model: [ {"type": "switch", "optionName": qsTr("Option 1")+trans.emptyString, "value" : option1Value}, {"type": "switch", "optionName": qsTr("Option 2")+trans.emptyString, "value" : option2Value}, {"type": "input", "optionName": qsTr("Option 3")+trans.emptyString, "value": option3Value} ] ListView { id: dataView clip: true spacing : 2 model: window.model delegate: OptionDelegate{} interactive: false }
What I have tried is that I use a property in my model called visibilty for example. And I use this property in order to change the visible property of my delegate. It work I don't see my delegate anymore but it leave a blank in the list and I don't want that.
Is there anyway to handle this ?
-
hi,
@DavidM29 said in Remove a ListElement from the ListView without removing it from the model:
it work I don't see my delegate anymore but it leave a blank in the list and I don't want that.
maybe you can try to set height to 0 when you set visible to false
height : visible ? theHeight : 0
-
@LeLev
Good idea I try it right away ! -
@LeLev
It works it is a very simple and good idea ! Thank you !