Reputation: 69
i can check with isVisible() if an widget is visible at all, but when the Flag QTool is set, it happens sometimes that the widget is in the stack under another widget, and so the user can't see it. Is there a method what gives me this information?
with regards Georg
Upvotes: 2
Views: 1099
Reputation: 2470
I had similar problem with PyQt5 on Windows. Qt methods visibleRegion()
or isVisible()
indicated that widget was visible when in fact it was not. The only solution that worked for me:
import win32gui, win32con # from pywin32 package
def is_widget_obscured(widget):
hwnd = widget.winId()
hwnd_above = win32gui.GetWindow(hwnd, win32con.GW_HWNDPREV)
return hwnd_above != 0
Documentation for GetWindow()
: https://learn.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getwindow
Upvotes: 0
Reputation: 3040
How about checking visibleRegion() method? If the item is covered, it will return an empty QRegion. You can check with isEmpty()
You can also bring the widget to the top using raise()
Upvotes: 1