Reputation: 53
I am trying to build an interactive map application which allow me to add and modify Map Items. I am able to add new map item but I still have problem to modify the model. On the code below, if I have more than one item, the remove
function always delete the first item crated not the current item selected. I want to modify the model not only the view of the model, but how can I get the currentIndex
of the model ?
ListModel {
id: mapModel
}
Map {
id: map
//...
MapItemView {
model: mapModel
delegate: MapCircle {
radius: 80000
color: 'blue'
center {
latitude: lat
longitude: longi
}
MouseArea {
onClicked: {
mapModel.remove(model.index)
}
}
}
}
MouseArea {
anchors.fill: parent
onClicked: {
var coord = map.toCoordinate(Qt.point(mouse.x,mouse.y))
mapModel.append({lat : coord.latitude, longi: coord.longitude});
}
}
}
Upvotes: 0
Views: 788
Reputation: 53
Found the answer myself. Just use mapModel.remove(index)
instead of mapModel.remove(model.index)
Upvotes: 1