Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.0, 6.2
Description
1. Create a button
2. Use the touch screen to tap the button
When the touch is over, the button is still in Hover state
By setting the WA_Hover property in style, you can control whether the Widget needs Hover events and status. But this is not a good solution for devices where touch screen and mouse exist at the same time
In SendMouseEvent, you can judge whether the mouse source comes from the system, and decide whether to send Enter Leave event, so as to control whether the Widget needs Hover event and status.
Is this reasonable?
--- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2365,7 +2365,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, if (event->type() == QEvent::MouseButtonRelease && !event->buttons()) *buttonDown = nullptr; } - } else if (lastMouseReceiver && widgetUnderMouse) { + } else if (lastMouseReceiver && widgetUnderMouse && event->source() == Qt::MouseEventSynthesizedBySystem) { // Dispatch enter/leave if we move: // 1) from an alien widget to another alien widget or // from a native widget to an alien widget (first OR case)