title: PyQt: updating GUI from a callback
body: <p>Using Python3 and PyQt4 I have a function (<strong>run</strong>) that takes as an input a callable to provide status updates.</p>
  
  <pre><code>class Windows(QtGui.QWidget):
      # Creates a widget containing:
      # - a QLineEdit (status_widget)
      # - a button, connected to on_run_clicked
  
      def on_run_clicked(self):
          def update(text):
              self.widget.setText(text)
  
          threading.Thread(target=run, args=(update, )).start()
  </code></pre>
  
  <p>This works ok (i.e. the text updates are displayed properly in the widget). However, when I replace <strong>QLineEdit</strong> by <strong>QTextEdit</strong> and use the <strong>append</strong> method to add text, I get:</p>
  
  <blockquote>
    <p>QObject::connect: Cannot queue arguments of type 'QTextCursor' </p>
    
    <p>(Make sure 'QTextCursor' is registered using qRegisterMetaType().)</p>
  </blockquote>
  
  <p>It still works but point to the fact that I am doing something wrong, and I am not sure that I will keep working when more threads are active. Usually, I do this type of updates using signals and slots, but the <strong>run</strong> function is not PyQt specific. The questions are:</p>
  
  <ol>
  <li>Why does it work without a warning for QLineEdit and not for
  QTextEdit? </li>
  <li>What is the right way to deal with a situation like this?</li>
  </ol>