4

I added some features in a layer. If I try to undo features from QGIS menu or Ctrl+Z can I capture that trigger?

I need like this:

def fun():
  print('UNDO')

iface.undo.triggered.connect(fun)

1 Answer 1

7

You must first access undo action (mActionUndo), then you can use its triggered event.

undo_action = [a for a in iface.digitizeToolBar().actions() if a.objectName() == "mActionUndo"][0]

def fun():
    print('UNDO')

undo_action.triggered.connect(fun)

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.