I want to remove all selection from registered layer in QGIS using Python. I tried to clear the map canvas using:
but the selection persists.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
There is probably a better way to do this, but you can iterate the layers in mapCanvas, and use removeSelection() method.
Something like this:
mc = self.iface.mapCanvas() For layer in mc.layers(): if layer.type() == layer.VectorLayer: layer.removeSelection() mc.refresh()