Originally Posted by
^NyAw^
Hi,
I know that using exec will make the thread to have it's own event loop, but I'm using the thread on the other behaviour. Practically it's a infinite loop(until a boolean value goes false) and the thread waits when there is no data to process. So in this case I can't use an event loop into the thread.
Yes You can. In example something like this :
class MySuperWorker
: public QThread{
.
.
.
protected:
void run();
slots :
void makePartOfJob();
}
void MySuperWork::run()
{
.
.
.
//activate one part of job
QTimer::singleShot(0,
this,
SLOT(makePartOfJob
()));
exec();
}
void MySuperWork::makePartOfJob()
{
//
//here do a part of job
//one course of old while loop
//
if( !end_of_job )
//activate next part of job
QTimer::singleShot(0,
this,
SLOT(makePartOfJob
()));
}
class MySuperWorker : public QThread
{
.
.
.
protected:
void run();
slots :
void makePartOfJob();
}
void MySuperWork::run()
{
.
.
.
//activate one part of job
QTimer::singleShot(0,this,SLOT(makePartOfJob()));
exec();
}
void MySuperWork::makePartOfJob()
{
//
//here do a part of job
//one course of old while loop
//
if( !end_of_job )
//activate next part of job
QTimer::singleShot(0,this,SLOT(makePartOfJob()));
}
To copy to clipboard, switch view to plain text mode
Bookmarks