[Qt-interest] QThread::run() running in wrong thread

Ove Fagerheim ove.fagerheim at nax.no
Sun May 23 14:32:31 CEST 2010


Can someone here help out a newbie?
I've created a new thread, but it seems like the thread's code is run
from the main thread, as shown by the fprintf statement. Where did I go
wrong?

class MyThread : public QThread
{
  .
  .
  void run() { fprintf(stderr, "MyThread is %p\n", thread(); }
  .
  .
};


int main(int argc, char *argv[])
{
  .
  .
  MyThread *thr = new MyThread();
  thr->start(); 
 .
  .
}

Ove




More information about the Qt-interest-old mailing list