Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Original center of QRectF which is Translated about a point (x,y)



  • As shown in the fig , I have a QRect A, where it's center is (cx,cy). I have translated it as follows
    A.translate(-p); where p is QPoint p (x,y).

    3f898aba-b056-4296-847c-6123ac76716b-image.png

    Now i have the the QRect A which already translated, Now with new translated QRect A how can i get the actual values of (cx,cy) ?
    Because A.center() will give me (cx1,cy1) not (cx,cy).



  • I think I got it...

    QRect A(0,0,1000,1000);
    So center (cx,cy) is (500,500)
    consider P(x,y) = P(1000,800)
    //I translated it as
    A.translate(-p);

    So now to get the original center back.
    A.translate(p)
    A.center() will give the original center...

    I think my understanding is correct.... Please correct me.


Log in to reply