[PyQt] other problem pyqt 4.6

Linos info at linos.es
Tue Oct 6 23:10:54 BST 2009

and other code sample as well, if i execute this code i get this error for every 
connect i try to do in the QThread run() method.

QObject: Cannot create children for a parent that is in a different thread.
(Parent is TestThread(0x99e09b8), parent's thread is QThread(0x98e60f0), current 
thread is TestThread(0x99e09b8)

---- CODE ----

# -*- coding: utf-8 -*-
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtSql import *

class TestWidget(QWidget):
     def __init__(self, parent):
         super(TestWidget, self).__init__()
         self.setMaximumSize(300, 200)

class TestThread(QThread):
     def __init__(self, parent=None):
         super(TestThread, self).__init__(parent)
         self.worker = None

     def run(self):
         self.worker = WorkerTest()

         self.connect(self.worker, SIGNAL("testSignal"), self, SIGNAL("testSignal"))


class WorkerTest(QObject):
     def __init__(self, parent=None):
         super(WorkerTest, self).__init__(parent)

def main():
     app = QApplication(sys.argv)

     widget = TestWidget(None)

     testThread = TestThread()

     return app.exec_()

if __name__ == "__main__":

---- CODE ----

I had no problems with this code and the last mail one with pyqt 4.4.4 (but 
maybe the problem is i am doing it incorrectly and the problem was in pyqt 4.4.4).

Best Regards,
Miguel Angel.

More information about the PyQt mailing list