Hello,

I googled a lot and went all over the internet (and Qt documentation) trying to find a quick solution, but I had no luck, so eventually I had to figure it out by myself.
This post is meant for this: just to give some quick reference to those are experiencing the same problem and need a fast idea of the solution.
Furthermore I saw many threads (not here) unanswered for this question, so I'm trying to give an answer (that at least for me worked).

I spent these days several hours trying to figure out how to use a QProcess object in a different thread without having qt complaining:
Cannot create children for a parent that is in a different thread.
because I was trying to create a QProcess to launch an external application from a different QThread than the main one.

This error pops up because with
Qt Code:
  1. MyThread::MyThread():QThread()
  2. {
  3. process=new QProcess(this); // QProcess process; in the class
  4. }
To copy to clipboard, switch view to plain text mode 
we are trying to tell that QProcess object's parent is our QThread subclass, but actually this QProcess object lives in the different thread we are going to launch, while MyThread object is, presumably, in the main thread. Actually different threads, Qt doesn't like this.

Solution is quite easy, but I was so fretful that I didn't notice it.
To get it work is just required to use the new thread as a new event loop (besides it is), and declare QProcess in the run() method instead of allocate it dinamically as a MyThread member pointer:
Qt Code:
  1. // this is all the class is made of
  2. void MyThread::run()
  3. {
  4. connect(&p,SIGNAL(finished(int)),this,SLOT(quit()));
  5. p->start("extprogram.exe");
  6. exec();
  7. }
To copy to clipboard, switch view to plain text mode 
p doesn't go prematurely out of scope until the end because exec() enters event loop and prevent it from being destroyed.
When process finishes execution, the connection calls the QThread's quit() slot that ends the thread; place a connection to the MyThread finished() signal in the main thread to know when it is over.

It was such a simple answer, I can't believe it took so much time to get fixed...
Maybe I am a dumb, but with this I hope to agile someone else's work.

Of course every comment on this is welcome.
HTH