TransWikia.com

Clearing QgsRubberBand

Geographic Information Systems Asked by Ehsan Aliverdi on January 26, 2021

I have several tools working with QGIS rubberband
before activating my new map tool i want to make sure there is nothing on rubberband
previously up to QGIS 3.2 I was able to clean the rubberband via the following code

rbs = [ i for i in canvas.scene().items()
                    if issubclass(type(i), qgis._gui.QgsRubberBand) ]
if len(rbs)>0:
                    for rb in rbs:
                        if rb in canvas.scene().items():
                            canvas.scene().removeItem(rb)

This code no longer works(as QGIS adds some default rubberband and when I try this QGIS crashes
now the question is how to have similar functionality (cleaning map canvas from all rubberbands before starting)

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP