title: Python new style signals and slot between thread and gui app
body: <p>I am newbie to OOP and python. I am trying to emit signal from Qthread to Qt GUI main window using new style signals and slots.</p>
  
  <p>This is the thread. Inside I will emit signals for updating message dialog in GUI after clicking RUN button in GUI and 3 seconds after that. I am not sure if the inheritance is defined OK or is the signal defined in the right manner.</p>
  
  <pre><code>class OptimThread (QtCore.QThread):
  
      signalUpdateMessageDialog = QtCore.SIGNAL("updateMessageDialog(PyQt_PyObject,QString)")
  
      def __init__(self):
          QtCore.QThread.__init__(self)
  
      def run(self):
  
          start = time.time()
  
          self.emit(self.signalUpdateMessageDialog, time.time() - start, 'Initialising...')     
  
          time.sleep(3)
  
          self.emit(self.signalUpdateMessageDialog, time.time() - start, 'You waited 3 seconds...')
  </code></pre>
  
  <p>The main class and the app part is like this (I omitted the other probably unrelevant code).</p>
  
  <pre><code>class Main(QtGui.QMainWindow, Ui_MainWindow):    
  
      def __init__(self, parent=None):
          super(Main, self).__init__(parent)
  
      def updateMessageDialog(self, times, dialog):  
  
          hours = str(datetime.timedelta(seconds=int(times)))
  
          self.MessageDialog.insertHtml('&lt;tt&gt;' + hours + ':&lt;/tt&gt; ' + dialog + '&lt;br&gt;')
  
          return
      def clickRun(self):
  
  
          self.optimThread = OptimThread()
  
          self.connect(self.optimThread, QtCore.SIGNAL("updateMessageDialog(PyQt_PyObject,QString)"), self.updateMessageDialog)
  
          #self.optimThread.signalUpdateMessageDialog.connect(self.updateMessageDialog)
  
          self.optimThread.start()
  
  if __name__ == '__main__':
      app=QtGui.QApplication(sys.argv)
      window=Main(None)
      app.setActiveWindow(window)
      window.show()
      sys.exit(app.exec_()) # Exit from Python
  </code></pre>
  
  <p>If evertyhing is written like this, It works.
  Yet if I want to use new style for connecting in Main:</p>
  
  <pre><code>self.optimThread.signalUpdateMessageDialog.connect(self.updateMessageDialog)
  </code></pre>
  
  <p>It says:   </p>
  
  <blockquote>
    <p>self.optimThread.signalUpdateMessageDialog.connect(self.updateMessageDialog)
    AttributeError: 'str' object has no attribute 'connect'</p>
  </blockquote>
  
  <p>I appreciate your advices (related to the subject and related to the style) and apologize for not making an MWE.</p>