def keyPressEvent(self, event): key = event.key() if key != Qt.Key_Backspace and key != Qt.Key_Enter: self.inactiveTextInPlace = False QLineEdit.keyPressEvent(self, event)
def focusOutEvent(self, event): if self.inactiveTextInPlace: self.setText(self.tr("Search...")) self.inactiveTextStyleSheet() QLineEdit.focusOutEvent(self, event)
def focusInEvent(self, event): if self.inactiveTextInPlace: self.clear() self.setStyleSheet("") QLineEdit.focusInEvent(self, event)