diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 7db77f5ee51..a4e44f5b8d8 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -410,16 +410,21 @@ void QEventPoint::setAccepted(bool accepted) /*! \obsolete - Deprecated since Qt 6.0. Use globalPosition() instead. + \fn QPointF QPointerEvent::normalizedPos() const + Deprecated since Qt 6.0. Use normalizedPosition() instead. +*/ + +/*! Returns the normalized position of this point. - The coordinates are normalized to QInputDevice::availableVirtualGeometry(), - i.e. (0, 0) is the top-left corner and (1, 1) is the bottom-right corner. + The coordinates are calculated by transforming globalPosition() into the + space of QInputDevice::availableVirtualGeometry(), i.e. \c (0, 0) is the + top-left corner and \c (1, 1) is the bottom-right corner. - \sa startNormalizedPos(), lastNormalizedPos(), pos() + \sa globalPosition() */ -QPointF QEventPoint::normalizedPos() const +QPointF QEventPoint::normalizedPosition() const { auto geom = d->device->availableVirtualGeometry(); if (geom.isNull()) @@ -449,7 +454,7 @@ QPointF QEventPoint::startNormalizedPos() const move event. The coordinates are normalized to QInputDevice::availableVirtualGeometry(), - i.e. (0, 0) is the top-left corner and (1, 1) is the bottom-right corner. + i.e. \c (0, 0) is the top-left corner and \c (1, 1) is the bottom-right corner. \sa normalizedPos(), startNormalizedPos() */ diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index f4cbf6f7af3..2459f1ba9d3 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -145,6 +145,7 @@ public: QPointF globalPressPosition() const; QPointF globalGrabPosition() const; QPointF globalLastPosition() const; + QPointF normalizedPosition() const; #if QT_DEPRECATED_SINCE(6, 0) // QEventPoint replaces QTouchEvent::TouchPoint, so we need all its old accessors, for now @@ -162,8 +163,8 @@ public: QPointF startScreenPos() const { return globalPressPosition(); } QT_DEPRECATED_VERSION_X_6_0("Use globalPressPosition()") QPointF startNormalizedPos() const; - QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()") - QPointF normalizedPos() const; + QT_DEPRECATED_VERSION_X_6_0("Use normalizedPosition()") + QPointF normalizedPos() const { return normalizedPosition(); } QT_DEPRECATED_VERSION_X_6_0("Use lastPosition()") QPointF lastPos() const { return lastPosition(); } QT_DEPRECATED_VERSION_X_6_0("Use sceneLastPosition()") diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index 3f87c21f513..bbd7cb22a07 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -81,7 +81,7 @@ public: touchBeginPoints = touchEvent->points(); Q_ASSERT(touchBeginPoints.first().device() == touchEvent->pointingDevice()); for (const QEventPoint &pt : qAsConst(touchBeginPoints)) - lastNormalizedPositions << pt.normalizedPos(); + lastNormalizedPositions << pt.normalizedPosition(); timestamp = touchEvent->timestamp(); deviceFromEvent = touchEvent->pointingDevice(); event->setAccepted(acceptTouchBegin); @@ -97,7 +97,7 @@ public: auto touchEvent = static_cast(event); touchUpdatePoints = touchEvent->points(); for (const QEventPoint &pt : qAsConst(touchUpdatePoints)) - lastNormalizedPositions << pt.normalizedPos(); + lastNormalizedPositions << pt.normalizedPosition(); timestamp = touchEvent->timestamp(); deviceFromEvent = touchEvent->pointingDevice(); event->setAccepted(acceptTouchUpdate); @@ -113,7 +113,7 @@ public: auto touchEvent = static_cast(event); touchEndPoints = touchEvent->points(); for (const QEventPoint &pt : qAsConst(touchEndPoints)) - lastNormalizedPositions << pt.normalizedPos(); + lastNormalizedPositions << pt.normalizedPosition(); timestamp = touchEvent->timestamp(); deviceFromEvent = touchEvent->pointingDevice(); event->setAccepted(acceptTouchEnd); @@ -702,11 +702,6 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() } } -QPointF normalized(const QPointF &pos, const QRectF &rect) -{ - return QPointF(pos.x() / rect.width(), pos.y() / rect.height()); -} - void tst_QTouchEvent::basicRawEventTranslation() { tst_QTouchEventWidget touchWidget;