From 6fe38482eeb27a5d591f977e198b34fb232c7040 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 20 Sep 2022 15:33:34 +0200 Subject: [PATCH] Rename QHoverEvent ctor pos argument to scenePos The QHoverEvent ctor takes two points: scenePos and globalPos; the first of those is passed to the QSinglePointEvent ctor as _both_ the local and scene pos, which calls QMutableEventPoint::setScenePosition() on the persistent QEventPoint instance, and then detaches before setting ephemeral state. Therefore, we must construct QHoverEvent with scene position, not local position, so that the right value is persisted. To localize a QHoverEvent during delivery, use QMutableEventPoint::setPosition(). This needs to be done repeatedly while visiting multiple widgets or items; the detach() prevents it from being saved in the persistent QEventPoint in QPointingDevicePrivate::EventPointMap. Amends 0a64a044b6c1c44b0a2bb2be5e70fda920f5f6bf Task-number: QTBUG-35409 Task-number: QTBUG-100324 Change-Id: Ic1084e1c3cd384683666ba52fe34f16b9d039877 Reviewed-by: Volker Hilsheimer (cherry picked from commit 9d6c1f387afda1a73df8cafb10d9b5bf883e5479) Reviewed-by: Qt Cherry-pick Bot --- src/gui/kernel/qevent.cpp | 8 ++++---- src/gui/kernel/qevent.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 82d04d3a56d..0eda9250f91 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -1025,15 +1025,15 @@ Qt::MouseEventFlags QMouseEvent::flags() const The \a type parameter must be QEvent::HoverEnter, QEvent::HoverLeave, or QEvent::HoverMove. - The \a pos is the current mouse cursor's position relative to the - receiving widget, \a oldPos is its previous such position, and + The \a scenePos is the current mouse cursor's position relative to the + receiving window or scene, \a oldPos is its previous such position, and \a globalPos is the mouse position in absolute coordinates. \a modifiers hold the state of all keyboard modifiers at the time of the event. */ -QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &globalPos, const QPointF &oldPos, +QHoverEvent::QHoverEvent(Type type, const QPointF &scenePos, const QPointF &globalPos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers, const QPointingDevice *device) - : QSinglePointEvent(type, device, pos, pos, globalPos, Qt::NoButton, Qt::NoButton, modifiers), m_oldPos(oldPos) + : QSinglePointEvent(type, device, scenePos, scenePos, globalPos, Qt::NoButton, Qt::NoButton, modifiers), m_oldPos(oldPos) { } diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 7bd393a0a91..6e9b2e21d89 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -238,7 +238,7 @@ class Q_GUI_EXPORT QHoverEvent : public QSinglePointEvent { Q_DECL_EVENT_COMMON(QHoverEvent) public: - QHoverEvent(Type type, const QPointF &pos, const QPointF &globalPos, const QPointF &oldPos, + QHoverEvent(Type type, const QPointF &scenePos, const QPointF &globalPos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers = Qt::NoModifier, const QPointingDevice *device = QPointingDevice::primaryPointingDevice()); #if QT_DEPRECATED_SINCE(6, 3)