- Game Programming using Qt 5 Beginner's Guide
- Pavel Strakhov Witold Wysota Lorenz Haas
- 190字
- 2021-08-27 18:31:02
The scene's coordinate system
Any item can be moved in the scene using the setPos() function. Try to call textItem->setPos(50, 50) and verify that the text was moved in the scene. Technically, this operation changes the transformation between the item's coordinate system and the scene's coordinate system. A convenience function called moveBy() allows you to shift the position by specified amounts.
An item can also be rotated with setRotation() and scaled with setScale(). Try calling textItem->setRotation(20) to see this in action. If you need a more advanced transformation, such as shearing, or you want to perform multiple translations in a particular order, you can create a QTransform object, apply the required transformations, and use the setTransform() function of the item.