4

In my QGIS python plugin I use self.iface.actionSelectRectangle().trigger() to select features. I also have a button which changes the attributes of the selected features.

Is there a way instead of using a button to change the attributes, to call the method automatically after a selection was made using self.iface.actionSelectRectangle().trigger().

Hugo Roussaffa
  • 2,191
  • 15
  • 40
Nicolas
  • 41
  • 1

1 Answers1

2

An answer is here : How to define an event for features selected in mapcanvas in qgis using python

You can connect your function to the selectionChanged signal of your vector layer

Example code from the related answer:

lyr=iface.activeLayer()
def myFunction(selFeatures):
   print str(len(selFeatures)) + " features were selected: " + str(selFeatures)

lyr.selectionChanged.connect(myFunction)

Each time you change the selection of your vector layer, myFunction is run.

YoLecomte
  • 2,895
  • 10
  • 23