title: How to can I add threading to PyQt5 GUI?
body: <p>So I have created a GUI using QT Designer.  It works pretty well, but on more complex calls it doesn't update the main window and locks up.  I want to run my <code>CustomComplexFunction()</code> while updating a textEdit in the main window from constantly changing backend information, and I wanted it to run every 2 seconds.  The following code seems right and runs without errors, but doesn't update the textEdit.  Please note i'm importing a .ui file designed from QT Designer with a pushButton and textEdit and the code won't run without it.</p>
  
  <p>Main.py</p>
  
  <pre><code>import sys
  from PyQt5.QtWidgets import QDialog, QApplication, QPushButton, QVBoxLayout, QMainWindow
  from PyQt5.QtCore import QCoreApplication, QObject, QRunnable, QThread, QThreadPool, pyqtSignal, pyqtSlot
  from PyQt5 import uic, QtGui
  
  class Worker(QObject):
      newParams = pyqtSignal()
  
      @pyqtSlot()
      def paramUp(self):
          x=1
          for x in range(100):
              time.sleep(2)
              self.newParams.emit()
              print ("sent new params")
              x +=1
  
  Ui_somewindow, _ = uic.loadUiType("mainwindow.ui") #the path to UI
  
  class SomeWindow(QMainWindow, Ui_somewindow, QDialog):
  
      def __init__(self):
  
          QMainWindow.__init__(self)
          Ui_somewindow.__init__(self)
          self.setupUi(self)
  
          # Start custom functions
          self.params = {}
          self.pushButton.clicked.connect(self.complex) #NumEvent
  
      def complex(self):
          self.work = Worker() 
          self.thread = QThread()
  
          self.work.newParams.connect(self.changeTextEdit)
          self.work.moveToThread(self.thread)
          self.thread.start()
  
          self.CustomComplexFunction()
  
      def CustomComplexFunction(self):
          self.params['City'] = 'Test'
  
      def changeTextEdit(self):
  
          try: 
              City = self.params['City']
              self.textEdit_14.setPlainText(City) 
          except KeyError:
              City = None
  if __name__ == "__main__":
  
      app = QApplication(sys.argv)
      window = SomeWindow()
      window.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>You can see the official docs for <a href="http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html" rel="nofollow noreferrer">Signals and Slots here</a> and this <a href="https://stackoverflow.com/questions/6783194/background-thread-with-qthread-in-pyqt">SO post</a> was also very helpful, but it seems like I built it correctly.  According to the docs, the emitter doesn't care if the signal is used. This might be why the code doesn't have errors but doesn't work either. </p>
  
  <p>Any ideas on how to make it work? Or atleast some way to test the emitter and signals??</p>