[Interest] QThreadPool functionality for QThreads

Frank Rueter | OHUfx frank at ohufx.com
Wed Jan 18 05:21:46 CET 2017


Hi,

I got another threading question for the pros out there:

In  my current application I am using QThread objects and 
QObject.moveToThread() to enable my GUI to download multiple files while 
updating progress bars in the main event loop. This is the respective 
snippet of code:
         self.worker = MyClass()
         self.workerThread = QtCore.QThread()
         self.worker.moveToThread(self.workerThread)


The trouble is when the user wants to download multiple files at once. 
In my current implementation that all works fine and I see multiple 
progress bars do there thing.
However, there are cases when I need to force the download threads to be 
synchronous. I had hoped that I can use QThreadPool with QThreads, but 
turns out I need QRunnables in this case, and those don't have the same 
signals as QThread.
So my question is:
Is there a good way to use QThreads in a queue which is controlled by 
the main thread, or should I re-write my code and subclass QRunnable to 
add the signals I need (i.e. the ones that QThread has by default)?
In the latter case I guess I'd have to inherit from both QObject and 
QRunnable, is this ok?


Cheers,
frank



-- 
ohufxLogo 50x50 <http://www.ohufx.com> 	*vfx compositing 
<http://ohufx.com/compositing.html> | *workflow customisation and 
consulting <http://ohufx.com/customising.html>* *

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170118/29986399/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ohufxLogo_50x50.png
Type: image/png
Size: 2666 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170118/29986399/attachment.png>


More information about the Interest mailing list