diff options
| author | Volker Hilsheimer <[email protected]> | 2021-04-16 11:29:12 +0200 |
|---|---|---|
| committer | Volker Hilsheimer <[email protected]> | 2021-04-17 09:18:11 +0200 |
| commit | 6a4aa096e9b9af08a81fe020d7f2ec8ceab7dfa6 (patch) | |
| tree | 6f1947836a76418943b1d9e2596026e2e9c8e85b /examples/widgets/painting/shared/hoverpoints.cpp | |
| parent | 7709463b55636305e6b35dccaf6c403fa5c3d72d (diff) | |
Port examples away from deprecated QTouchEvent APIs
Use the QEventPoints API instead.
Change-Id: I7310fd34df110cad508f6188a41ad452a3cf848d
Reviewed-by: Shawn Rutledge <[email protected]>
Diffstat (limited to 'examples/widgets/painting/shared/hoverpoints.cpp')
| -rw-r--r-- | examples/widgets/painting/shared/hoverpoints.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/examples/widgets/painting/shared/hoverpoints.cpp b/examples/widgets/painting/shared/hoverpoints.cpp index 9fe947cedc0..417d593d042 100644 --- a/examples/widgets/painting/shared/hoverpoints.cpp +++ b/examples/widgets/painting/shared/hoverpoints.cpp @@ -176,12 +176,12 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) case QEvent::TouchUpdate: { const QTouchEvent *const touchEvent = static_cast<const QTouchEvent*>(event); - const QList<QTouchEvent::TouchPoint> points = touchEvent->touchPoints(); + const auto points = touchEvent->points(); const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height()); - for (const QTouchEvent::TouchPoint &touchPoint : points) { - const int id = touchPoint.id(); - switch (touchPoint.state()) { - case Qt::TouchPointPressed: + for (const auto &point : points) { + const int id = point.id(); + switch (point.state()) { + case QEventPoint::Pressed: { // find the point, move it const auto mappedPoints = m_fingerPointMapping.values(); @@ -197,7 +197,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) if (activePoints.contains(i)) continue; - qreal d = QLineF(touchPoint.position(), m_points.at(i)).length(); + qreal d = QLineF(point.position(), m_points.at(i)).length(); if ((distance < 0 && d < 12 * pointSize) || d < distance) { distance = d; activePoint = i; @@ -206,25 +206,25 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) } } if (activePoint != -1) { - m_fingerPointMapping.insert(touchPoint.id(), activePoint); - movePoint(activePoint, touchPoint.position()); + m_fingerPointMapping.insert(point.id(), activePoint); + movePoint(activePoint, point.position()); } } break; - case Qt::TouchPointReleased: + case QEventPoint::Released: { // move the point and release QHash<int,int>::iterator it = m_fingerPointMapping.find(id); - movePoint(it.value(), touchPoint.position()); + movePoint(it.value(), point.position()); m_fingerPointMapping.erase(it); } break; - case Qt::TouchPointMoved: + case QEventPoint::Updated: { // move the point const int pointIdx = m_fingerPointMapping.value(id, -1); if (pointIdx >= 0) // do we track this point? - movePoint(pointIdx, touchPoint.position()); + movePoint(pointIdx, point.position()); } break; default: |
