Reputation: 189
For example
ListView {
id: listView
anchors.fill: parent
anchors.margins: 20
model: myModel
delegate: myDelegate
highlightFollowsCurrentItem: true
focus: true
ListModel {
id: myModel
ListElement {
name: "Apple"; cost: 2.45
attributes: [
ListElement { description: "Core" },
ListElement { description: "Deciduous" }
]
isOnMouse: false
}
}
I use myDelegate as default for any model, but if one of the item is clicked i whant to use another delegate for this item, only for this item.
Is it possible?
Upvotes: 0
Views: 1715
Reputation: 2112
If you use the QML Loader
element as your delegate, then you should be able to change its source
or sourceComponent
, effectively changing your delegate for a single item.
Upvotes: 1
Reputation: 450
In your main item define:
property boolean isItem:false
in your delegate make:
onClicked: isItem=index==myIndex
where myIndex descripe your special item
in the listView set :
delegate: isItem? otherDel : myDelegate
Upvotes: 1