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().

1 Answer 1


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:

def myFunction(selFeatures):
   print str(len(selFeatures)) + " features were selected: " + str(selFeatures)


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.