Rotate QGraphicsItem - It does not over its center


I'm trying to rotate a QGraphicsItem on its own center, so it does not move its center, just turn X degrees ... I can not make it happen, it changes places, as if the whole scene were spinning but the rest of the Elements do not turn ... but he turns but not over his center. I leave the code to see if they give me a hand. Thanks a thousand.

QRectF rect;
rect = engine->boundingRect();
QPointF center =;
qreal angle = grade;
QTransform t;
t.translate(center.x(), center.y());
t.translate(-center.x(), -center.y());
engine->setRotation(engine->rotation() + angle);

Engine is the QGraphicsItem that I want to rotate on its center ...

asked by Emiliano Torres 31.05.2018 в 16:39

1 answer


Thanks to @Trauma's note I leave you here as I solved my problem in case someone serves you. All the code of the question I replaced simply by the following:

engine->setRotation(engine->rotation() - grade);
answered by 31.05.2018 / 19:38