Skip to content

Instantly share code, notes, and snippets.

@sivabudh
Created October 19, 2015 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sivabudh/846b622d19f6fecf9f47 to your computer and use it in GitHub Desktop.
Save sivabudh/846b622d19f6fecf9f47 to your computer and use it in GitHub Desktop.
Worker and QThread
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