QTransform.rotate() from the middle point?



  • Hello. I want my QTransform rotating from the middle point of my QLine (so, if my QLine is 50 pixels long, it should rotate from X 25 for example)! At the moment it rotates from the left point, so from X 0. How to do this?



  • I guess you have to translate the line so that its middle point lays on the rotation axis. Then you can rotate around this axis and afterwards you can translate your line back using the inverse of your previous translation.

    Beware that translating an object and then rotating it gives a different result as first rotating it and then translating it even if the translation distance and the rotation angle is the same: This kind of coordinate transformations are not commutative.



  • Yup! I had to translate. But I solved it myself already. Thanks anyways!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.