Hi.
I try to delete Graphics in QML.
My code is
onMouseClicked: {
clickPointBuilder.points.addPoint(cPoint)
wayPointMakeGraphic.geometry = clickPointBuilder.geometry
clickPointLineBuilder.addPoint(cPoint)
wayPointLineMakeGraphic.geometry = clickPointLineBuilder.geometry
}
Item{
focus: true
if(event.key === Qt.Key_C){
console.log("OK CLEAR")
clickPointBuilder.points.removeAll()
clickPointLineBuilder.parts.removeAll()
}
}
But, This code have a flaw.
I want to delete it when I press the C Key.
It will be deleted when I click the screen again after pressing the C key.
How to delete Graphics?
Solved! Go to Solution.
Simply updating the builder will not update the graphic's geometry. After you removeAll() on the builders, you need to set the geometry on wayPointMakeGraphic and wayPointLineMakeGraphic from the builders again, as you do in your onMouseClicked method. This should set the geometries on the graphics to valid, but empty geometries.
Simply updating the builder will not update the graphic's geometry. After you removeAll() on the builders, you need to set the geometry on wayPointMakeGraphic and wayPointLineMakeGraphic from the builders again, as you do in your onMouseClicked method. This should set the geometries on the graphics to valid, but empty geometries.
Thanks.
I can do it.