code: def keyPressEvent(self, event):
          
          if event.key() in [Qt.Key_Enter, Qt.Key_Return]:
              self._parent.process_text()
              if self._parent.is_valid():
                  self._parent.keyPressEvent(event)
          else:
              QLineEdit.keyPressEvent(self, event)
docs: Qt override.