-1

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 Answers1

1

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)
samdavydov
  • 564
  • 3
  • 22
  • okay so I made a slot within my arrow class (QGraphicsPixmapItem) and connected it to a timer. However it only rotates once before the program crashes. Is this problem familiar? – Maria Mattar Oct 17 '20 at 09:19
  • Smth is definitely wrong with your code. Unintialized variables, dangling pointers, out of bounds array index, double deletion, etc. Can't say more without source code – samdavydov Oct 17 '20 at 11:52