How to rotate an QGraphicsPixmapItem in Qt

425 views Asked by At

I am trying to rotate an image in Qt. If you try this game, you can easily see how the arrow is rotating: https://www.friv.com/z/games/killcovid19/game.html?Desktop-x-x-w-x-x-xx

Assuming my image is in a QGraphicsPixmapItem, how should I make it rotate?

1

There are 1 answers

2
samdavydov On BEST ANSWER

First, you need to set the rotation point (bottom-right/left in your case)

void QGraphicsItem::setTransformOriginPoint(qreal x, qreal y)

And then perform a rotation around the transform point

void QGraphicsItem::setRotation(qreal angle)