Created
January 9, 2017 19:45
-
-
Save SEVEZ/e4c5f5518f3723a4074e0999ff8ed6e8 to your computer and use it in GitHub Desktop.
Get all widgets under cursor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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