title: Calling functions between PyQt5 classes in Python
body: <p>I'm trying to call a function in the main class with the PyQt5 button &quot;<code>dropEvent</code>&quot; event in Python. Although the &quot;<code>print(&quot;setText&quot;)</code>&quot; command in the function works, the next &quot;<code>self.lbl_1.setText(&quot;setText&quot;)</code>&quot; command does not work.</p>
  <p><strong>Code:</strong></p>
  <pre><code>from PyQt5.QtWidgets import *
  from PyQt5.QtGui import *
  from PyQt5.QtCore import *
  
  class Button(QPushButton):
      def __init__(self, title, parent):
          super(Button, self).__init__(title, parent)
          self.setAcceptDrops(True)
  
      def dragEnterEvent(self, event):
          if event.mimeData().hasFormat('text/plain'):
              event.accept()
          else:
              event.ignore() 
  
      def dropEvent(self, event):
          self.setText(event.mimeData().text())
          MainWindow().lbl_setText()
  
  
  class MainWindow(QMainWindow):
      def __init__(self):
          super().__init__()
  
          self.setGeometry(100, 100, 200, 150)
          self.setWindowTitle(&quot;Example&quot;)
  
          self.setup()
      
      def setup(self):
          self.btn_quit = Button('Quit', self)
          self.btn_quit.clicked.connect(QApplication.instance().quit)
          self.btn_quit.resize(self.btn_quit.sizeHint())
          self.btn_quit.move(90, 100)
          self.btn_quit.setAcceptDrops(True)
  
          self.le_drag = QLineEdit('', self)
          self.le_drag.setDragEnabled(True)
          self.le_drag.move(50, 50)
  
          self.lbl_1= QLabel('Hi', self)
          self.lbl_1.move(50, 10)
  
      def closeEvent(self, event: QCloseEvent):
          reply = QMessageBox.question(self, 'Message', &quot;r u sure!&quot;,
                                  QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
      
          if reply == QMessageBox.Yes:
              event.accept()
          else:
              event.ignore()
  
      def lbl_setText(self):
          print(&quot;setText&quot;)
          self.lbl_1.setText(&quot;setText&quot;)
  
  def main():
      app = QApplication([])
      app.setStyle(&quot;Fusion&quot;)
      mainWin = MainWindow()
      mainWin.show()
      app.exec()
  
  if __name__ == '__main__':
      main()
  </code></pre>