Do we have onclick event handler for textboxes in PyQt5, like we have in JQuery and C# ?
If not, Is there any other way of handling clicks on textboxes ?
Do we have onclick event handler for textboxes in PyQt5, like we have in JQuery and C# ?
If not, Is there any other way of handling clicks on textboxes ?
Some widgets (such as QLineEdit) don't have a clicked signal out of the box. But you can make a custom widget that inherits from the widget you need, give it a clicked signal, and emit it on mousePressEvent.
class CustomLineEdit(QtWidgets.QLineEdit):
clicked = QtCore.pyqtSignal()
def __init__(self):
super().__init__()
def mousePressEvent(self, QMouseEvent):
self.clicked.emit()
Then you can just connect the clicked signal to whatever you want.
self.line_edit = CustomLineEdit()
self.line_edit.clicked.connect(self.handle_click)