title: Clear QLineEdit on click event
body: <p>I am using the given code, I want the user to enter text in the QLineEdit widget, press the Copy! button and see the inputted text replace the 'N/A' label. My questions is: following this procedure, how can I clear the text inputted in the QLineEdit widget with a simple mouse click?</p>
  <p>From what I read (<a href="https://www.developpez.net/forums/d979566/autres-langages/python-zope/gui/pyqt/probleme-focusoutevent-qlineedit/" rel="noreferrer">this</a>, <a href="https://riverbankcomputing.com/pipermail/pyqt/2008-March/018831.html" rel="noreferrer">this</a> and <a href="https://stackoverflow.com/questions/6452077/how-to-get-click-event-of-qlineedit-in-qt">this</a>) it seems like I need to reimplement focusInEvent() in a new class extending QLineEdit. My problem is that the code for my GUI has been imported from Qt Designer using pyuic5 and the examples cited above don't seem to take this in consideration.</p>
  <p>Here is my code:</p>
  <pre><code>from PyQt5.QtWidgets import *
  import sys
  
  import QLineEdit_test
  
  
  class MainWindow(QMainWindow, QLineEdit_test.Ui_QLineEdit_test):
  
      def __init__(self, parent=None):
          super(MainWindow, self).__init__(parent)
          self.setupUi(self)
  
          self.copy_button.clicked.connect(self.copy_and_print)
  
      def copy_and_print(self):
  
          self.label.setText(self.lineEdit.text())
  
  
  def main():
  
      app = QApplication(sys.argv)
      form = MainWindow()
      form.show()
      app.exec_()
  
  if __name__ == &quot;__main__&quot;:
      main()
  </code></pre>
  <p>Here is my converted .ui file:</p>
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  
  class Ui_QLineEdit_test(object):
      def setupUi(self, QLineEdit_test):
          QLineEdit_test.setObjectName(&quot;QLineEdit_test&quot;)
          QLineEdit_test.resize(300, 200)
          QLineEdit_test.setMaximumSize(QtCore.QSize(300, 200))
          self.centralwidget = QtWidgets.QWidget(QLineEdit_test)
          self.centralwidget.setObjectName(&quot;centralwidget&quot;)
          self.gridLayout_2 = QtWidgets.QGridLayout(self.centralwidget)
          self.gridLayout_2.setObjectName(&quot;gridLayout_2&quot;)
          self.gridLayout = QtWidgets.QGridLayout()
          self.gridLayout.setObjectName(&quot;gridLayout&quot;)
          self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
          self.lineEdit.setMaximumSize(QtCore.QSize(120, 16777215))
          self.lineEdit.setObjectName(&quot;lineEdit&quot;)
          self.gridLayout.addWidget(self.lineEdit, 0, 0, 1, 1)
          self.copy_button = QtWidgets.QPushButton(self.centralwidget)
          self.copy_button.setObjectName(&quot;copy_button&quot;)
          self.gridLayout.addWidget(self.copy_button, 1, 0, 1, 1)
          self.label = QtWidgets.QLabel(self.centralwidget)
          self.label.setMaximumSize(QtCore.QSize(200, 20))
          self.label.setAlignment(QtCore.Qt.AlignCenter)
          self.label.setObjectName(&quot;label&quot;)
          self.gridLayout.addWidget(self.label, 2, 0, 1, 1)
          self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
          QLineEdit_test.setCentralWidget(self.centralwidget)
          self.menubar = QtWidgets.QMenuBar(QLineEdit_test)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 300, 22))
          self.menubar.setObjectName(&quot;menubar&quot;)
          QLineEdit_test.setMenuBar(self.menubar)
          self.statusbar = QtWidgets.QStatusBar(QLineEdit_test)
          self.statusbar.setObjectName(&quot;statusbar&quot;)
          QLineEdit_test.setStatusBar(self.statusbar)
  
          self.retranslateUi(QLineEdit_test)
          QtCore.QMetaObject.connectSlotsByName(QLineEdit_test)
  
      def retranslateUi(self, QLineEdit_test):
          _translate = QtCore.QCoreApplication.translate
          QLineEdit_test.setWindowTitle(_translate(&quot;QLineEdit_test&quot;, &quot;MainWindow&quot;))
          self.copy_button.setText(_translate(&quot;QLineEdit_test&quot;, &quot;Copy!&quot;))
          self.copy_button.setShortcut(_translate(&quot;QLineEdit_test&quot;, &quot;Return&quot;))
          self.label.setText(_translate(&quot;QLineEdit_test&quot;, &quot;N/A&quot;))
  </code></pre>