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

Phil Thompson phil at riverbankcomputing.com
Sat Oct 5 10:31:13 BST 2013


On Fri, 04 Oct 2013 16:07:38 +1000, Stephen Gava <elguavas at gmail.com>
wrote:
> 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?

Do you have a small, complete test case that demonstrates the problem?

Phil


More information about the PyQt mailing list