Skip to content

Instantly share code, notes, and snippets.

@SEVEZ
Created January 9, 2017 19:45
Show Gist options
  • Save SEVEZ/e4c5f5518f3723a4074e0999ff8ed6e8 to your computer and use it in GitHub Desktop.
Save SEVEZ/e4c5f5518f3723a4074e0999ff8ed6e8 to your computer and use it in GitHub Desktop.
Get all widgets under cursor
def widgets_at( pos ):
"""Return ALL widgets at `pos`
Arguments:
pos (QPoint): Position at which to get widgets
"""
widgets = []
widget_at = qApp.widgetAt( pos )
while widget_at:
widgets.append( widget_at )
# Make widget invisible to further enquiries
widget_at.setAttribute( Qt.WA_TransparentForMouseEvents )
widget_at = qApp.widgetAt( pos )
# Restore attribute
for widget in widgets:
widget.setAttribute( Qt.WA_TransparentForMouseEvents, False )
return widgets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment