[PyQt] pyqt5.1 QWidget.childAt() exception

Stephen Gava elguavas at gmail.com
Fri Oct 4 07:07:38 BST 2013


i've found another puzzling (to me) difference in behaviour between 
pyqt5 and pyqt4.

using pyqt4 this works without any problem:

child_widget=self.parent_widget.childAt(self.parent_widget.mapFromGlobal(QCursor.pos()))

returning the child widget under the cursor, which i can then use in 
subsequent operations, whether the toplevel parent window is active or not.

using pyqt5 (pyqt 5.1 with qt 5.1 on linux x64) it works if the toplevel 
parent window is active, however if the toplevel parent window is 
inactive, trying to use the returned reference child_widget in any way 
throws a confusing (to me) exception, which, in the case of the widgets 
i'm using is:

AttributeError: 'QLabel' object has no attribute 'QWidget'

can anyone shed any light on this?

thanks,
stephen.


More information about the PyQt mailing list