From 5f2eee18c918ffb136fa2c491127f933e53345fe Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 3 May 2017 15:13:01 +0200 Subject: [PATCH] tablet example: use stylus rotation property correctly It was backwards from the expected value, consistently on iOS and xcb. It was already that way in 5.6, and we don't document which way is clockwise. So it seems to be just the example which is wrong. Change-Id: Ibbdadc2ae240017abc87439a2694fb5fbd3d07f8 Reviewed-by: Andy Shaw --- examples/widgets/widgets/tablet/tabletcanvas.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/widgets/widgets/tablet/tabletcanvas.cpp b/examples/widgets/widgets/tablet/tabletcanvas.cpp index 54e8544a3d..9812c29554 100644 --- a/examples/widgets/widgets/tablet/tabletcanvas.cpp +++ b/examples/widgets/widgets/tablet/tabletcanvas.cpp @@ -174,13 +174,13 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event) painter.setBrush(m_brush); QPolygonF poly; qreal halfWidth = pressureToWidth(lastPoint.pressure); - QPointF brushAdjust(qSin(qDegreesToRadians(lastPoint.rotation)) * halfWidth, - qCos(qDegreesToRadians(lastPoint.rotation)) * halfWidth); + QPointF brushAdjust(qSin(qDegreesToRadians(-lastPoint.rotation)) * halfWidth, + qCos(qDegreesToRadians(-lastPoint.rotation)) * halfWidth); poly << lastPoint.pos + brushAdjust; poly << lastPoint.pos - brushAdjust; halfWidth = m_pen.widthF(); - brushAdjust = QPointF(qSin(qDegreesToRadians(event->rotation())) * halfWidth, - qCos(qDegreesToRadians(event->rotation())) * halfWidth); + brushAdjust = QPointF(qSin(qDegreesToRadians(-event->rotation())) * halfWidth, + qCos(qDegreesToRadians(-event->rotation())) * halfWidth); poly << event->posF() - brushAdjust; poly << event->posF() + brushAdjust; painter.drawConvexPolygon(poly); @@ -313,7 +313,7 @@ void TabletCanvas::updateCursor(const QTabletEvent *event) QPainter painter(&img); QTransform transform = painter.transform(); transform.translate(16, 16); - transform.rotate(-event->rotation()); + transform.rotate(event->rotation()); painter.setTransform(transform); painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); painter.drawImage(-24, -24, origImg);