Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

qt c++ thread example

Worker* worker = new Worker(mythingy);
QThread* thread = new QThread();
worker->moveToThread(thread);
thread->start();

//wrong: directly invoking doWork in mainthread    
worker->doWork();

//correct: through signal-slot mechanics
connect(this, SIGNAL(startWork()), worker, SLOT(doWork()));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #qt #thread
ADD COMMENT
Topic
Name
2+1 =