Hi,<br><br>I have a problem with passing signals a cross threads. <br>I was under the impression that when using Qt.QueuedConnection the slot would always be executed in the thread that the receiver object lived.&nbsp; But when I created this test application I does not seem to be doing that. Any suggestions on what the error might be?
<br><br>Btw, I&#39;m working on a tutorial on using signal and slots with python over at <a href="http://developernew.kde.org/Development/Tutorials/101_Python_introduction_to_signal_and_slots">http://developernew.kde.org/Development/Tutorials/101_Python_introduction_to_signal_and_slots
</a> <br>Feel free to improve it. Feedback and suggestions are also most welcome. English is not my native language so I guess there are plenty of mistakes :/<br><br>from PyQt4.QtGui import *<br>from PyQt4.QtCore import *
<br>import sys<br><br>class MyUI(QMainWindow):<br>&nbsp;&nbsp;&nbsp; def __init__(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QMainWindow.__init__(self)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.list=QListWidget()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.setCentralWidget(self.list)<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; def newItem(self,item):
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.list.addItem(item)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>class MyWorkerThread(QThread):<br>&nbsp;&nbsp;&nbsp; def __init__(self,ui):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QThread.__init__(self)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ui=ui<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; def run(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.connect(self,SIGNAL(&quot;createdItem&quot;),self.ui.newItem,Qt.QueuedConnection) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for i in range (1,10):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #creating items<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.emit(SIGNAL(&quot;createdItem&quot;),i)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.exec_()<br><br>if __name__==&quot;__main__&quot;:<br>&nbsp;&nbsp;&nbsp; app=QApplication(sys.argv)<br>&nbsp;&nbsp;&nbsp; window=MyUI()<br>&nbsp;&nbsp;&nbsp; window.show()<br>&nbsp;&nbsp;&nbsp; worker=MyWorkerThread(window)<br>&nbsp;&nbsp;&nbsp; worker.start()&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; app.exec_()<br><br><br>
This code outputs:<br>QObject: Cannot create children for a parent that is in a different thread.<br>