diff options
Diffstat (limited to 'examples/widgets/painting/shared/hoverpoints.cpp')
-rw-r--r-- | examples/widgets/painting/shared/hoverpoints.cpp | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/examples/widgets/painting/shared/hoverpoints.cpp b/examples/widgets/painting/shared/hoverpoints.cpp index 7d2bb81538..a917139613 100644 --- a/examples/widgets/painting/shared/hoverpoints.cpp +++ b/examples/widgets/painting/shared/hoverpoints.cpp @@ -6,10 +6,6 @@ #include <algorithm> -#if QT_CONFIG(opengl) -#include <QtOpenGL/QOpenGLWindow> -#endif - HoverPoints::HoverPoints(QWidget *widget, PointShape shape) : QObject(widget), m_widget(widget), @@ -131,6 +127,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) const int id = point.id(); switch (point.state()) { case QEventPoint::Pressed: + case QEventPoint::Stationary: { // find the point, move it const auto mappedPoints = m_fingerPointMapping.values(); @@ -155,7 +152,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) } } if (activePoint != -1) { - m_fingerPointMapping.insert(point.id(), activePoint); + m_fingerPointMapping.insert(id, activePoint); movePoint(activePoint, point.position()); } } @@ -163,9 +160,11 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) case QEventPoint::Released: { // move the point and release - const auto it = m_fingerPointMapping.find(id); - movePoint(it.value(), point.position()); - m_fingerPointMapping.erase(it); + const auto it = m_fingerPointMapping.constFind(id); + if (it != m_fingerPointMapping.constEnd()) { + movePoint(it.value(), point.position()); + m_fingerPointMapping.erase(it); + } } break; case QEventPoint::Updated: @@ -230,17 +229,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) void HoverPoints::paintPoints() { QPainter p; -#if QT_CONFIG(opengl) - ArthurFrame *af = qobject_cast<ArthurFrame *>(m_widget); - if (af && af->usesOpenGL() && af->glWindow()->isValid()) { - af->glWindow()->makeCurrent(); - p.begin(af->glWindow()); - } else { - p.begin(m_widget); - } -#else p.begin(m_widget); -#endif p.setRenderHint(QPainter::Antialiasing); @@ -268,7 +257,7 @@ void HoverPoints::paintPoints() p.setPen(m_pointPen); p.setBrush(m_pointBrush); - for (const auto &point : qAsConst(m_points)) { + for (const auto &point : std::as_const(m_points)) { QRectF bounds = pointBoundingRect(point); if (m_shape == CircleShape) p.drawEllipse(bounds); |