title: Run a new thread Qt C++
body: <p>i want to run code in a seperate thread of the main application, for that i hava created some file :</p>
  
  <p>thread2.h</p>
  
  <pre><code>#ifndef THREAD2_H
  #define THREAD2_H
  #include &lt;QThread&gt;
  
  class thread2 : public QThread
  {
      Q_OBJECT
  
  public:
      thread2();
  
  protected:
      void run();
  
  };
  
  #endif // THREAD2_H
  </code></pre>
  
  <p>thread2.cpp</p>
  
  <pre><code>#include "thread2.h"
  
  thread2::thread2()
  {
      //qDebug("dfd");
  }
  void thread2::run()
  {
      int test = 0;
  }
  </code></pre>
  
  <p>And the main file called main.cpp</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QThread&gt;
  #include "thread1.cpp"
  #include "thread2.h"
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
  
      thread2::run();
  
      return a.exec();
  }
  </code></pre>
  
  <p>But it dosen't work...</p>
  
  <p>Qt Creator tell me : "cannot call member function 'virtual void thread2::run()' without object"</p>
  
  <p>Thanks !</p>