如何在 Qt 中旋转 QGraphicsPixmapItem

How to rotate an QGraphicsPixmapItem in Qt

我正在尝试在 Qt 中旋转图像。如果你尝试这个游戏,你可以很容易地看到箭头是如何旋转的: https://www.friv.com/z/games/killcovid19/game.html?Desktop-x-x-w-x-x-xx

假设我的图像在 QGraphicsPixmapItem 中,我应该如何让它旋转?

首先,您需要设置旋转点(bottom-right/left在您的情况下)

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

然后围绕变换点进行旋转

void QGraphicsItem::setRotation(qreal angle)