def keyPressEvent(self, event): if event.key() == Qt.Key_Delete: self.delete() return QTreeView.keyReleaseEvent(self, event)