title: Confusion regarding QThread, QObject, Thread Affinity and Event Loop
body: <p>I was going through the links</p>
  
  <ol>
  <li><a href="http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/" rel="nofollow">You are doing it wrong</a></li>
  <li><a href="http://blog.debao.me/2013/08/how-to-use-qthread-in-the-right-way-part-1/" rel="nofollow">Using QThread in right way Part1</a></li>
  <li><a href="http://blog.debao.me/2013/08/how-to-use-qthread-in-the-right-way-part-2/" rel="nofollow">Using QThread in right way Part2</a></li>
  </ol>
  
  <p>I got confused by some statements. In the first link, it says that</p>
  
  <blockquote>
    <p>all of the functions in QThread were written and intended to be called from the creating thread, not the thread that QThread starts.</p>
  </blockquote>
  
  <p>while  it suggests to use <code>moveToThread</code> to move an object to new thread, instead of subclassing <code>QThread</code>. My question is:</p>
  
  <p>The default implementation of <code>run</code> method calls <code>exec</code>, which creates an <em>event loop</em>, and when an object's <em>thread affinity</em> is changed using <code>moveToThread</code>, all the <code>slots</code> will be executed in the <strong>new thread</strong>, not on the <strong>creating thread</strong>, which is contradictory with the aforementioned <em>intended use</em>. Am I missing something?</p>
  
  <p><strong>Second question:</strong></p>
  
  <p>In the third link it is said</p>
  
  <blockquote>
    <p>event queue is belong to thread instead of event loop, and it’s shared by all the event loops running in this thread.</p>
  </blockquote>
  
  <p>My question is <em>how there can be more than one event loop in a single thread</em> ? What I understand is, <em>event-loop</em> loop through the <em>event-queue</em>, until <code>exit</code>/<code>terminate</code> is called, and processes each <code>event</code> arrives on that queue. If this is true, one loop will never end (unless  <code>exit</code>/<code>terminate</code> is called), how another can begin? Any sample code demonstrating it will be highly appreciated.</p>