Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我从继承QGraphicsObject并创建了一个具有像素图并将其变换原点设置为的新类:
QGraphicsObject
setTransformOriginPoint(boundingRect().center());
但是当我调用setRotation()我的类(QGraphicsView使用场景添加到一个)时,旋转不使用中心作为旋转锚。如何将中心设置为旋转的锚点?谢谢 !
setRotation()
QGraphicsView
更多信息:在场景事件函数之外调用 setRotation() 可以工作,但在场景事件内部,在捏合手势时,原点不起作用。
在 处绘制像素图QRect(0, 0, pixmap.width(), pixmap.height()。也使用这个矩形来包围矩形。用于setPos在场景中移动项目。用于setTransformOriginPoint(pixmap.width() / 2, pixmap.height() / 2)设置原点。这些坐标位于项目坐标中,因此无论项目的位置如何,它们都应指向像素图的中心。
QRect(0, 0, pixmap.width(), pixmap.height()
setPos
setTransformOriginPoint(pixmap.width() / 2, pixmap.height() / 2)