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. Update a QGraphicsItem bounding rectangle after a transformation

Update a QGraphicsItem bounding rectangle after a transformation

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.5k 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.
  • B Offline
    B Offline
    Ben13
    wrote on last edited by
    #1

    Hello !
    I'm using setRotation() on a QGraphicsPolygonItem and I would like to get the bounding rectangle after the rotation using boundingRect(), but it doesn't change with the transformation.
    I tried using prepareGeometryChange() in a subclass of QGraphicsPolygonItem but I can't get it work, I probably made a mistake since I'm new to this kind of things.
    Can someone explain me how to use prepareGeometryChange(), or tell me any other way to update the bounding rectangle after the rotation ?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      katana
      wrote on last edited by
      #2

      Does someone have any idea about this?
      I've come across the same problem.

      Thanks in advance

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Asperamanca
        wrote on last edited by
        #3

        From the docs:
        "the bounding rect is always rectangular, and it is unaffected by the items' transformation."

        The bounding rect is given in item coordinate space, therefore it does not change when you rotate the item. If e.g. you want the bounding rect of an item as seen in scene coordinates, you need to map it, e.g. using
        pYourItem->mapRectToScene(boundingRect());

        The output of this mapping will change when you rotate the item.

        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