QProgressDialog and QTConcurrent::run
-
Hi,
Let say I want to download 100 pictures in multiple threads, but not 100. So I use something like:
@void MainW::makePmap()
{
...
for(int threadNr=0;threadNr<data->m_maxThreads;threadNr++)
QtConcurrent::run(loadPMapInThread,data);
...
}
@the function called lookes like:
@
void loadPMapInThread( SDLM_DATA * data )
{
...
}
@Now every time one of the threads finished one picture (map) it should send a signal to the main thread, so that this can update a QTProgressDialog. As far as I understand the signal slot system I would use emit inside of loadPMapInThread to send a signal and use a slot in the MainW to receive it and update the ProgressDialog. But what I don't understand is the function connect:
bool QObject::connect ( const QObject * sender, const char * signal, const QObject * receiver, const char * method, Qt::ConnectionType type = Qt::AutoConnection ) [static]
The receiver is MainW and method the receiving slot, signal is what I use with emit, but what do I set sender to? loadPMapInThread is not member of a class derrived from QObject.
And the same problem will ocure if I want to connect a signal to cancel the download when the cancel-Button of dthe QProgressDialog is pressed.
Dimitri -
thanks, that looks fine. I finished programming it and did some tests.
Dimitri