[Qgis-developer] QgsVertexMarker modified class: Plot moving points over a map at fixed rate

Martin Dobias wonder.sk at gmail.com
Tue Jul 7 18:06:06 EDT 2009


On Tue, Jul 7, 2009 at 4:41 PM, Luca Pascale<pascale.luca.it at gmail.com> wrote:
> Hi all,
>
> I have modified the class QgsVertexMarker and the plugin to plot at a fixed
> rate some points over the map with a custom icon. (previous mail below)
>
> How can I delete a Marker from the map ?
> I try to delete the QgsVertexMarker object using "del" in python but it free
> the memory but the icon is ever over the map.
> My actual solution is to "hide" the marker using no custom icon but this
> method still paints something (not visible) on the screen.

use following code to delete a marker:
canvas.scene().removeItem(marker)

Canvas items are assigned canvas as a parent. This means that if
canvas is being deleted and the item still exists, it gets deleted
too. In c++ it's enough to delete the marker instance and it's gone.
However in Python if you do "del marker" you actually delete only the
reference, not the real object because it is owned by the canvas. By
explicitly removing the item you make sure it won't be shown anymore.

Martin


More information about the Qgis-developer mailing list