From 6a4aa096e9b9af08a81fe020d7f2ec8ceab7dfa6 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 16 Apr 2021 11:29:12 +0200 Subject: Port examples away from deprecated QTouchEvent APIs Use the QEventPoints API instead. Change-Id: I7310fd34df110cad508f6188a41ad452a3cf848d Reviewed-by: Shawn Rutledge --- .../widgets/painting/pathstroke/pathstroke.cpp | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'examples/widgets/painting/pathstroke/pathstroke.cpp') diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp index 412c2da6a4..bfa588f201 100644 --- a/examples/widgets/painting/pathstroke/pathstroke.cpp +++ b/examples/widgets/painting/pathstroke/pathstroke.cpp @@ -622,11 +622,11 @@ bool PathStrokeRenderer::event(QEvent *e) case QEvent::TouchUpdate: { const QTouchEvent *const event = static_cast(e); - const QList points = event->touchPoints(); - for (const QTouchEvent::TouchPoint &touchPoint : points) { - const int id = touchPoint.id(); - switch (touchPoint.state()) { - case Qt::TouchPointPressed: + const auto points = event->points(); + 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(); @@ -638,32 +638,32 @@ bool PathStrokeRenderer::event(QEvent *e) 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 * m_pointSize) || d < distance) { distance = d; activePoint = i; } } if (activePoint != -1) { - m_fingerPointMapping.insert(touchPoint.id(), activePoint); - m_points[activePoint] = touchPoint.position(); + m_fingerPointMapping.insert(point.id(), activePoint); + m_points[activePoint] = point.position(); } break; } - case Qt::TouchPointReleased: + case QEventPoint::Released: { // move the point and release QHash::iterator it = m_fingerPointMapping.find(id); - m_points[it.value()] = touchPoint.position(); + m_points[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) - m_points[pointIdx] = touchPoint.position(); + m_points[pointIdx] = point.position(); break; } default: -- cgit v1.2.3