title: Qt get a threads ID in the main thread?
body: <p>I have some issues with this:</p>
  
  <p>First I create my object and move it to a thread: </p>
  
  <pre><code>FileUploader *fileUploader = new FileUploader(fileList_, start, (offset == 0 ? (fileList_.count() - start) : offset));
  QThread *fileUploaderThread = new QThread;
  fileUploader-&gt;moveToThread(fileUploaderThread);
  
  fileUploaderThreads_.append(fileUploaderThread);
  fileUploaders_.append(fileUploader); // contains pointers to the objects
  
  connect(fileUploader, SIGNAL(progressChangedAt(int)), model_, SLOT(reportProgressChanged(int)), Qt::QueuedConnection);
  connect(fileUploader, SIGNAL(statusChangedAt(int)), model_, SLOT(reportStatusChanged(int)), Qt::QueuedConnection);
  connect(fileUploader, SIGNAL(finished()), fileUploaderThread, SLOT(quit()), Qt::QueuedConnection);
  connect(fileUploaderThread, SIGNAL(finished()), this, SLOT(checkIfFinished()), Qt::QueuedConnection);
  </code></pre>
  
  <p>The in the slot checkIfFinished() I wanna go though all the threads and see if they quit. 
      qDebug() &lt;&lt; "one thread done";</p>
  
  <pre><code>foreach(QThread *thread, fileUploaderThreads_) { // or FileUploader* fileuploader, fileUploaders_ ?
      if(thread &amp;&amp; !thread-&gt;isFinished()) {
  
          qDebug() &lt;&lt; "not finished " &lt;&lt; thread-&gt;currentThreadId();
  
          return; // not done
      }
  }
  </code></pre>
  
  <p>When this is printed out, I only get the main thread Id, not the threads. I tried to print the threads id's out but with no luck (after they are started ofc). 
  The reason why I'm doing this I because the person writing "Advanced Qt Programming - Mark S" did a similar thing with QThreads that he placed in a list and checked if they where finished. The only thing thats working now is the connection which kills the thread when the fileUploader is done.</p>
  
  <p>Also, how do I store pointers for the threads? I wounder how I will be able to delete them all if they don't seem to point to the right threads. </p>
  
  <p>Edit:</p>
  
  <p>I tried to store the QObjects in a list instead and do this:</p>
  
  <pre><code>QThread *senderx = qobject_cast&lt;QThread*&gt;(sender());
  
  qDebug() &lt;&lt; "one thread done" &lt;&lt; senderx;
  
  foreach(FileUploader *fileUploader, fileUploaders_) {
      if(fileUploader &amp;&amp; !fileUploader-&gt;thread()-&gt;isFinished()) {
  
          qDebug() &lt;&lt; "not finished " &lt;&lt; fileUploader-&gt;thread();
  
          return; // not done
      }
  }
  //done 
  qDebug() &lt;&lt; "done";
  setButtonState(false);
  </code></pre>
  
  <p>And my outprint on the last call is :</p>
  
  <blockquote>
    <p>one thread done QThread(0x43ee180) </p>
    
    <p>not finished  QThread(0x43ee180) </p>
  </blockquote>
  
  <p>How is this possible? It is done, but the method says otherwise. </p>