def keyPressEvent(self, event): key = event.key() if key != Qt.Key_Backspace and key != Qt.Key_Enter: self.inactiveTextInPlace = False QLineEdit.keyPressEvent(self, event)