Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Original center of QRectF which is Translated about a point (x,y)
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 250 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • DonCoderD Offline
    DonCoderD Offline
    DonCoder
    wrote on last edited by DonCoder
    #1

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

    1 Reply Last reply
    0
    • DonCoderD Offline
      DonCoderD Offline
      DonCoder
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved