i'm using model view in qml.
ListView{
id: targetParameter
width: parent.width
height: parent.height
anchors.top: parent.top
anchors.left: parent.left
anchors.leftMargin: 20
spacing: 10
orientation: ListView.Horizontal
interactive: false
model: proxyModelCharacterization
delegate: ParameterChangeTarget {
paramWidht: {
if(name === "NAME"){
targetParameter.width * 0.11
}else{
targetParameter.width * 0.42
}
}
paramHeight: targetParameter.height * 0.95
}
}
with this list view, I have three elements (for example Rectangle). rect1, rect2, rect3. i want to swap rect2 and rect3, but i can't change the order in which they are instantiated on my controller.
how can i swap two element on list view? every kind of help or suggestion are greatly appreciated.
You can use the
.move()method to move an element in aListModel.In the following example, the elements are added in the
ListModelonce, in theComponent.onCompletedsignal. You can then move them up or down (in the model and hence, the view) by clicking on the corresponding buttons. The buttons use themove()method ofListModel.Example: