O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What just happened?

Most transformations depend on the origin point of the coordinate system. For rotation and scaling, the origin point is the only point that remains in place. In the preceding example, we used a rectangle with the top-left corner at (50, 50) and the size of (50, 50). These coordinates are in the item's coordinate system. Since we originally didn't move the item, the item's coordinate system was the same as the scene's coordinate system, and the origin point is the same as the scene's origin (it's the point marked with the cross). The applied rotation uses (0, 0) as the center of rotation, thus providing an unexpected result.

There are multiple ways to overcome this problem. The first way is to change the transform's origin ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required