Inside a QML ListView, i'd like to call a function when a MouseArea is clicked:
ListView{
anchors.fill: parent
orientation: ListView.Horizontal
model: myModel
delegate:
Rectangle {
anchors.fill: parent
Text {
anchors.centerin: parent
text: label
}
MouseArea {
width: 30
height: parent.height
onClicked: {
doSomething()
}
}
}
}
I's supposed to be an overflow-menu. In the ListModel (myModel) i want to be able to say what happens when doSomething() is called. How do i do that? Maybe like so?
ListModel {
id: myModel
ListElement {
label: "New"
doSomething: {
canvas.clear()
}
}
}
I have no idea. I searched the web, but i couldn't find anything.
I'm using a ListView/Model for this because i want to add and remove menu-entries dynamically.
Thanks for your attention! =)
doSomething()or modifying the model fromdoSomething()? - BaCaRoZzo