Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to correctly Connect from qthreadpool
I develop a small program, where i add in a Loop multiple small Tasks to a Threads.
If the Work ist done i want to add a Line to a qlist.
But how did i correctly Connect that Tasks to emit the Signal? Or is there a way to Check from qthreadpool when the Task ist finished?
Greetz from germany
Do you mean from your QRunnable subclass ?
PXLFuSSeL last edited by PXLFuSSeL
thats what i mean.
i have implemented a QRunnable to do that work.
Then i loop through a list were the params in, create an object, connect the signal and slot, and start the work with pool->start().
But all i get is "Function recv() failed" on console but no entrie in my list.
Is that correct? Or shall i implement an own kind of threadpool?
You'll have the progress indication for free.
I know Threadpools from python and thought it works the same way.
But ok i will give that a shot.
QImage scaled(const QImage &image)
return image.scaled(100, 100);
QList<QImage> images = ...;
QFuture<QImage> thumbnails = QtConcurrent::mapped(images, scaled);
Yes, adding a QFutureWatcher in the mix.
hey is there also a way to get the already compute results while running?
So i want to update the gui, as soon as an results is computed.
Or isnt it a good idea?
@PXLFuSSeL You get the result from QFuture and then update the GUI. Using QFutureWatcher (as @SGaist suggested) you also get notification when a job is finished and then use QFuture to get the result.
@jsulm yes that is implemented, but i am interested in getting a result as soon as it is calculated, because am working with really big lists
As already hinted twice, QFutureWatcher is your friend.
@SGaist yes, thx, my fault was trying to iterate through the future until not be ready.
now i got what i want, not as fast as i want, but it works stable.