Should QGraphicsItem::boundingRect() include child bounding rects?

后端 未结 3 1753
南方客
南方客 2021-01-18 14:39

Googling suggests that it should.

But the dragdroprobot example implementation (on the parent Robot object) suggests not:

QRectF Robot::boundingRect(         


        
3条回答
  •  清歌不尽
    2021-01-18 15:10

    Possibly related:

    1. QGraphicItemGroup is different.

    The documentation says:

    The boundingRect() function of QGraphicsItemGroup returns the bounding rectangle of all items in the item group.

    (However, the documentation does not say that boundingRect is reimplemented, although QGraphicsItemGroup inherits QGraphicsItem. Thats probably a flaw in the documentation.)

    1. QGraphicItem.shape() seems to be similar to boundingRect() in that the view calls it for each instance (for purposes of picking i.e. QGraphicsView.items(), similarly as boundingRect() is called for purposes of determining what needs to be redrawn).

    As far as I can tell, QGraphicItemGroup.shape() is never called by QGraphicsView.items(). The documentation does not say that it is reimplemented.

提交回复
热议问题