title: In which thread do functions live that are called by QThread's run method?
body: <p>It is quite clear from the Qt documentation (<a href="https://doc.qt.io/qt-5/qthread.html" rel="nofollow noreferrer">https://doc.qt.io/qt-5/qthread.html</a>) that subclassing QThread is no longer the recommended way of using multi-threading (instead you should create a QObject and move it to another thread) as the <code>run</code> method is the only thing living in the new thread when subclassing.</p>
  <p>However, I have a number of old projects subclassing QThread, which are running fine, but after reading the QThread doc I wonder in which thread functions are being executed that are called inside QThread’s <code>run</code> method.</p>
  <p>To make it more clear, here is an example code:</p>
  <p>helperThread.h:</p>
  <pre><code>#ifndef HELPERTHREAD_H
  #define HELPERTHREAD_H
  
  #include &lt;QThread&gt;
  
  class helperThread : public QThread
  {
      Q_OBJECT
  
  public:
      helperThread();
      ~helperThread();
  
      void memberFunc();
      void run() override;
  
  signals:
      void resultReady(const QString &amp;s);
  };
  
  #endif // HELPERTHREAD_H
  </code></pre>
  <p>helperThread.cpp:</p>
  <pre><code>#include &quot;helperthread.h&quot;
  
  helperThread::helperThread()
  {
      this-&gt;start();
  }
  
  helperThread::~helperThread()
  {
  
  }
  
  void noMemberFunc()
  {
      // this static function is no member of helperThread
      // some code
  }
  
  void helperThread::memberFunc()
  {
      // this function is a member of helperThread
      // some code
  }
  
  void helperThread::run()
  {
      noMemberFunc(); // in which thread is this function living?
      memberFunc(); // and in which thread is this func living?
  
      QString result = &quot;result...&quot;;
      emit resultReady(result);
  }
  </code></pre>
  <p>As far as I understand, <code>helperThread</code> and all its methods excluding <code>run</code> live in the old thread (in my case just the MainWindow), while the code inside <code>run</code> is executed in a new thread, so that it doesn’t block the old one.</p>
  <p>However, I put two functions inside the <code>run</code> method in the above example (a member function and a non-member function).</p>
  <p>Are they executed in the new thread (that of <code>run</code>) and thus not blocking my main thread, or are they executed in the old thread (and thus blocking it)?</p>
  <p>And is there any command to test in which thread I am currently?</p>