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

Timothy W. Grove tim_grove at sil.org
Sat Oct 5 09:19:25 BST 2013


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

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
>



More information about the PyQt mailing list