Hello, I want to rotate the pixmap of the QGraphicsPixmap item and show the item rotated. Rotating the item cause other sort of problems.
So far, I never had problems when rotating the pixmaps, but I don't know why now the rotation is not taking from the center and rotates the pixmap, it's like its rotated without the translation and I don't know why.
//m_pxOriginal is a copy of the original pixmap. Not rotated.
qreal rRadius = m_pxOriginal.width() / 2;
//Rotate the previous rotation - 10 degrees
m_iAngle -= 10;
QPixmap rotatedPix
= m_pxOriginal .
transformed(QTransform
().
translate(-rRadius,
-rRadius
).
rotate(m_iAngle
).
translate(rRadius, rRadius
));
m_pxItem->setPixmap(rotatedPix);
//m_pxOriginal is a copy of the original pixmap. Not rotated.
qreal rRadius = m_pxOriginal.width() / 2;
//Rotate the previous rotation - 10 degrees
m_iAngle -= 10;
QPixmap rotatedPix = m_pxOriginal .transformed(QTransform().translate(-rRadius, -rRadius).rotate(m_iAngle).translate(rRadius, rRadius));
m_pxItem->setPixmap(rotatedPix);
To copy to clipboard, switch view to plain text mode
Anything strange? :S thanks!
Bookmarks