Where is the QGIS API action for "deselect"?

You can get the attributes toolbar and iterate through its actions (buttons) until you get the "deselect" one. Then you can trigger it.

Try this in your QGIS Python console:

for a in iface.attributesToolBar().actions(): 
  if a.objectName() == 'mActionDeselectAll':
    a.trigger()
    break

In QGIS 3.4 using Python Console, also is

iface.activeLayer() 
vlayer.removeSelection()

I was stuck on the same issue. I found in http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/vector.html#selecting-features

layer.setSelectedFeatures([])

it will just select an empty list and so clear selection.

Tags:

Pyqgis