Hi - I'm having problems with the following code where a QRunnable emits
a signal then ends. If you click the button it should print 1,2,3. It
sometimes works for the first few times but the wrong number of
arguments is given to the slot after that.
I'm using 4.8.3 on Linux (x86).
Is this a PyQt bug? I assume one of the objects is getting reference
counted between the end of the runnable and signal it emits being
delivered, but I may be wrong.
I've tried setting autodelete on the runnable to be false but that
causes a crash. The code works if you emit and connect to an object
which isn't a member of the runnable class.
Is there an easy way to signal a result from a QRunnable? I've worked
around this problem by replacing the code with a worker thread and a
semaphore.
Jeremy
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class Runnable(QRunnable):
def __init__(self):
QRunnable.__init__(self)
self.obj = QObject()
def run(self):
self.obj.emit(SIGNAL("testsignal"), 1, 2, 3)
class Win(QPushButton):
def __init__(self):
QPushButton.__init__(self, "Push me")
self.tp = QThreadPool()
self.connect(self, SIGNAL("clicked()"), self.slotClicked)
def slotClicked(self):
runnable = Runnable()
self.connect(runnable.obj, SIGNAL("testsignal"), self.slotTestSignal)
self.tp.start(runnable)
def slotTestSignal(self, a, b, c):
print "Returning from runnable", a, b, c
if __name__ == '__main__':
app = QApplication(sys.argv)
w = Win()
w.show()
app.exec_()
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt