[PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'

Stephen Gava elguavas at gmail.com
Sat Oct 5 10:50:21 BST 2013



On 05/10/13 18:19, Timothy W. Grove wrote:
> Hi Stephen,
>
> I don't really understand the issues here, but I also saw these kinds of
> errors cropping up recently when I moved an application from PyQt4 to
> PyQt5. I think I had at least three different cases of "AttributeError:
> 'Qxxxxxx' object has no attribute 'QWidget'". One case I fixed by not
> giving a parent to the instance I was creating, simply, 'instance =
> SomeWidgetClass(self, parent=None)'; another I fixed by actually giving
> it a parent (!), and for the third case I just had to write different
> code to accomplish my task.
>
> Sorry this isn't very specific but maybe it will give you something to
> try. I'm hoping its just a bug in PyQt5 which will sort itself out
> somewhere down the line ...
>
> Best regards,
> Tim
>


thanks Tim, at least for letting me know i'm not going mad here. ;)

i'm going to see if i can put together a small test case that 
demonstarates the problem for Phil, but as you've noted here this seems 
to happen in a very unpredictable way so i'm not sure how i'll go.

regards,
stephen.


> On 05/10/2013 07:02, Stephen Gava wrote:
>> hi there,
>> i posted an earlier question about one specific instance of this
>> problem which seemed to relate to using QWidget.childAt() (no
>> replies), but now i have the same puzzling issue cropping up in
>> several places in a project i have moved from pyqt4 to pyqt5.
>>
>> under pyqt4 this code ran fine with none of these exceptions.
>>
>> under pyqt5 i'm getting exceptions of the kind detailed in the message
>> title from time to time, ie exceptions where the final error message is:
>>
>>  AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
>>
>> where Qxxxxxx is some kind of widget (in one instance QLabel, in
>> another couple of cases QMainWindow).
>>
>> these errors seem like they might be comming from pyqt5 itself, as i
>> don't reference QWidget as an attribute of any labels or mainwindows
>> in my own code, however the tracebacks i get only follow the stack in
>> my own code, in one instance this exception is thrown after a call to
>> QWidget.childAt() and in some other instances after calls to
>> QWidget.window()  (which was Qwidget.topLevelWidget() in pyqt4).
>>
>> as i said the pyqt4 version never throws these exceptions, and i can't
>> find anything in my code that should be causing this under pyqt5...
>>
>> does anyone have any advice on how i can at least try to work out
>> where the issue is coming from? it's definitely caused by something
>> new/different in ptqt5.
>>
>> thanks,
>> stephen.
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt


More information about the PyQt mailing list