Created
October 19, 2015 05:09
-
-
Save sivabudh/846b622d19f6fecf9f47 to your computer and use it in GitHub Desktop.
Worker and QThread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Worker : public QObject | |
{ | |
Q_OBJECT | |
public slots: | |
void doWork() { | |
/* … */ | |
} | |
}; | |
/* … */ | |
QThread *thread = new QThread; | |
Worker *worker = new Worker; | |
connect(obj, SIGNAL (workReady()), worker, SLOT (doWork())); | |
worker->moveToThread(thread); | |
thread->start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment