[PyQt] Help with PyQt5 QThread parent argument

Phil Thompson phil at riverbankcomputing.com
Fri Jan 17 09:35:58 GMT 2014


On 17-01-2014 12:26 am, David Cortesi wrote:
> I have a QThread subclass that begins so:
>
>> class WorkerBee ( QThread ) :
>>     statusChanged = pyqtSignal(int, int)
>>     def __init__(self, parent=None):
>>          super().__init__(parent)
>
> In PyQt4 I instantiate this from a QMainWindow with:
>
>>  self.worker = WorkerBee() # i.e. no parent
>
> In PyQt5 (5.2, sip 4.15.4) this produces the error,
>
> builtins.TypeError: descriptor '__init__' requires a
> 'sip.simplewrapper' object but received a 'NoneType'
>
> However if I pass the main window as parent,
>
>>  self.worker = WorkerBee(self)
>
> I then get the error,
>
> builtins.AttributeError: 'theAppWindow' object has no attribute 'run'
>
> Per the PyQt4 reference and the Qt5 C++ reference, the parent 
> argument
> should be a QObject and anyway is optional. What am I doing wrong?

Please post a complete script that demonstrates the problem. A simple 
test based on the above works fine.

Phil


More information about the PyQt mailing list