When editing the attribute table of a shapefile in QGIS (2.14.8 ltr) using a value relation field (one or multiple choices) in formular view, hitting Ctrl-A selects all attribute table entries; subsequently hitting Backspace or Delete deletes all content - geometry and attributes. There is no warning. There is no way to restore the entry besides turning off the editing mode without saving your changes.

I'm not even sure if this is intended behaviour. Anyone knows a way to prevent that?

FTR, I also lost single entries by hitting Del or Backspace when entering data, and this inspired my post. However, I couldn't reproduce this on purpose, but if I find out how, I'll come back to this post for an update.

1 Answer 1


There is also another way of restoring your deleted features instead of turning off the editing mode which is to go back to the QGIS main window and then press Ctrl+Z (or from the menubar: Edit > Undo). This should return the features which can immediately be seen in the Attribute Table either in table or form view.

But if you want to completely prevent features being deleted by those keys, you may have to use a bit of Python. For example, if you post the following code into the Python Console, it will set the Del and Backspace keys to do absolutely nothing:

from PyQt4.QtGui import QShortcut, QKeySequence
from PyQt4.QtCore import Qt

def blank():

keys = [Qt.Key_Delete, Qt.Key_Backspace]
for x in keys:
    shortcut = QShortcut(QKeySequence(x), iface.mainWindow())
  • 1
    I'll test the Ctrl+Z suggestion. It doesn^t do the trick in the attribute table, that's for sure. Thanks for the python code, I'll look into that, too ASAP.
    – aae
    Jul 4, 2017 at 11:44
  • @WilliamBligh - You're right in that it won't work from the Attribute Table, might be a useful feature to implement though :)
    – Joseph
    Jul 4, 2017 at 11:47

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.