title: QT + How to call slot from custom C++ code running in a different thread
body: <p>I am new to QT and I am doing some learning.</p>
  
  <p>I would like to trigger a slot that modify a GUI widget from a C++ thread(Currently a Qthread).</p>
  
  <p>Unfortunatly I get a: ASSERTION failed at: Q_ASSERT(qApp &amp;&amp; qApp->thread() == QThread::currentThread()); </p>
  
  <p>here is some code:</p>
  
  <p>(MAIN + Thread class)</p>
  
  <pre><code>   class mythread : public QThread
      {
      public:
          mythread(mywindow* win){this-&gt;w = win;};
          mywindow* w;
          void run()
          {
              w-&gt;ui.textEdit-&gt;append("Hello");        //&lt;--ASSERT FAIL
              //I have also try to call a slots within mywindow which also fail.
          };
      };
  
      int main(int argc, char *argv[])
      {
          QApplication* a = new QApplication(argc, argv);
          mywindow* w = new mywindow();
  
          w-&gt;show();
          mythread* thr = new mythread(w);
          thr-&gt;start();
  
          return a-&gt;exec();
      }
  </code></pre>
  
  <p>Window:</p>
  
  <pre><code>class mywindow : public QMainWindow
  {
      Q_OBJECT
  
  public:
      mywindow (QWidget *parent = 0, Qt::WFlags flags = 0);
      ~mywindow ();
      Ui::mywindow ui;
  
  private:
  
  
  
  public slots:
      void newLog(QString &amp;log);
  };
  </code></pre>
  
  <p>So I am curious on how to update the gui part by code in a different thread.</p>
  
  <p>Thanks for helping</p>