Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.8.2
Description
Reproducer attached. There is a root QWidget with a child QWidget within. That child QWidget has it enter and leave events overridden. On entry, it's going to show another QWidget. And on leaving, it's going to hide that QWidget.
The setup is simple, but the problem lies in the window flag and attribute specified, i.e.:
topWidget->setWindowFlags(Qt::Tool); topWidget->setAttribute(Qt::WA_TransparentForMouseEvents, true); // topWidget->setWindowFlags(Qt::Tool);
in line 14~16. Namely, the "popped up" QWidget is a tooltip and it ignores mouse event. The problem is:
On Windows:
If Qt::Tool is set first (how it is written in the first place), then moving mouse cursor inside red QWidget will cause enter/leaveEnter to be registered repeatedly. The other way around (comment out line 14 and uncomment 16) is fine. Moreover, if either Qt::Tool or Qt::WA_TransparentForMouseEvents is used alone (either comment out setAttribute or both setWindowFlags), you'd see the same "events being spammed" problem.
On macOS:
If Qt::Tool is set first, then everything is fine. The other way around, then moving mouse cursor inside red QWidget will cause enter/leaveEnter to be registered repeatedly. It is the opposite of Windows behavior. Moreover, if you use Qt::WA_TransparentForMouseEvents alone (comment out both setWindowFlags), you'd see the same "events being spammed" problem. Using Qt::Tool alone is fine. So it is another inconsistency, comparing to Windows behavior.
Update: a one-line solution for macOS only: use Qt::Popup instead of Qt::Tool. For Windows, strangely it only works when
setWindowFlags(Qt::FramelessWindowHint | Qt::Popup | Qt::NoDropShadowWindowHint);
is executed first.
Attachments
Issue Links
- relates to
-
QTBUG-134253 Certain combination of window flag and attribute may conflict on macOS
-
- Reported
-