QGraphicsItem - Bounding rect for item, and all children? [solved]



  • Simple question: I can call boundingRect to get the bouding box of a given item. Is it possible to get the bounding box of an item, and all its children, without writing extra methods? is there some built in method? Thanks.



  • [quote author="Qt Assistant" date="0"]QRectF QGraphicsItem::childrenBoundingRect () const

    Returns the bounding rect of this item's descendants (i.e., its children, their children, etc.) in local coordinates. The rectangle will contain all descendants after they have been mapped to local coordinates. If the item has no children, this function returns an empty QRectF.

    This does not include this item's own bounding rect; it only returns its descendants' accumulated bounding rect. If you need to include this item's bounding rect, you can add boundingRect() to childrenBoundingRect() using QRectF::operator|().

    This function is linear in complexity; it determines the size of the returned bounding rect by iterating through all descendants.[/quote]



  • Fantastic, thanks for the tip.



  • You are welcome. Assistant contains a lot of info, you only need to find it. Please don't forget to mark thread as [solved] (by editing its title)


Log in to reply
 

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