[PyQt] Threaded communication

Mads Ipsen mads.ipsen at gmail.com
Mon Feb 16 18:12:35 GMT 2015


Suppose I have a worker object

class Worker(QObject):

     def addTasks(self, tasks):

which has been moved to a QThread using 'moveToThread', and then started 
from there.

* From the main thread, when I add new tasks to the worker, must I 
always use

   tasks = ['sleep', 'work', 'run']
   arg = QtCore.Q_ARG(object, tasks)
   Core.QMetaObject.invokeMethod(self._worker, 'addTasks', 
QtCore.Qt.QueuedConnection, arg)

or can I call this directly, like


Observe that I pass a pure Python list from the main thread to the 
worker (not a QStringList).

Best regards,


| Mads Ipsen                                                          |
| Overgaden Oven Vandet 106, 4.tv  | phone:              +45-29716388 |
| DK-1415 KĂžbenhavn K              | email:      mads.ipsen at gmail.com |
| Denmark                          | map  : https://goo.gl/maps/oQ6y6 |

More information about the PyQt mailing list