As the previous poster pointed out, it is easier and cleaner to just create a worker-object that communicates only through signals and slots and move that to a QThread instance.
You can ask it to start working either by connecting it to a "start working signal" that is emitted in the main thread or by invoking it indirectly from the main thread by using the static QMetaobject::invokeMethod() call.
Something like:
worker = new WorkerClass();
connect(worker,
SIGNAL(response
(QString)),
this,
SLOT(response
(QString)));
worker->moveToThread(t);
QMetaObject::invokeMethod(worker,
"startWorking",Qt
::QueuedConnection);
worker = new WorkerClass();
connect(worker,SIGNAL(response(QString)),this,SLOT(response(QString)));
QThread *t = new QThread();
t->start(QThread::IdlePriority);
worker->moveToThread(t);
QMetaObject::invokeMethod(worker,"startWorking",Qt::QueuedConnection);
To copy to clipboard, switch view to plain text mode
Bookmarks