Note that there are some explanatory texts on larger screens.

plurals
  1. POPyQt4 Worker thread, a "QThread.started" goes missing
    text
    copied!<p>I am trying to properly setup a worker thread in my PyQt4 application, but for some reason the start signal from the thread is no propagating to my worker!</p> <pre><code> syncThread = QtCore.QThread() self._syncThread = syncThread worker = SyncWorker(self.async_sync) worker.moveToThread(syncThread) syncThread.started.connect(self.progress.show) #This dialog appears! syncThread.started.connect(worker.work) # This seems to be a no-op worker.finished.connect(syncThread.quit) worker.finished.connect(worker.deleteLater) syncThread.finished.connect(worker.deleteLater) syncThread.finished.connect(syncThread.deleteLater) syncThread.start() class SyncWorker(QtCore.QObject): # Emitted whenever done finished = QtCore.pyqtSignal() def __init__(self, delegate): QtCore.QObject.__init__(self) @QtCore.pyqtSlot() def work(self): print("Worker gonna work") #This never prints! self.finished.emit() </code></pre> <p>Any ideas?</p> <p>Thank you!</p> <p><strong>Update:</strong> After renaming worker -> self.worker as per Gary Hughes I get a new error before a crash</p> <pre><code>QObject::setParent: Cannot set parent, new parent is in a different thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread QPixmap: It is not safe to use pixmaps outside the GUI thread python: Fatal IO error 11 (Resource temporarily unavailable) on X server :0. Segmentation fault </code></pre> <p><strong>Update #2</strong> Nevermind! My worker was calling GUI code and that caused the new error. The original fix of using self.worker is correct.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload