[Qt-interest] QThreadPool, Qrunnable and Signals/Slots
Michael Jackson
mike.jackson at bluequartz.net
Fri Dec 18 18:40:58 CET 2009
I would like to have a long running task put on another thread. I have done
things like this before with Qt but seem to get mixed up with Qthread,
Signals, Slots and Event Loops.
My basic design is to have a "WorkerTask" derive from QObject and QRunnable
and implement the following:
virtual void run()
signals:
taskMessage(const QString &)
taskProgress(int )
taskFinished()
slots:
cancelTask()
Then in the main GUI Class I plan to hook up the task with the GUI using
Signals/Slots
connect( task, SIGNAL(taskMessage(cons QString &)), this,
SLOT(recTaskMessage(const QString &)) );
... Connect the rest
QThreadPool->globalInstance()->start(task);
Is this going to work? I have read through the docs on QThreadPool and can
not get an indication if each thread in the QThreadPool runs its own event
loop? Without an event loop the Signals/Slots will not be delivered? Is that
correct?
Should I be tackling this in another way?
Thanks for any advice/pointers
Mike Jackson
More information about the Qt-interest-old
mailing list