Important: Please read the 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).


    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 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

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

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

Log in to reply