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

后端 未结 3 1751
南方客
南方客 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:03

    Child items are painted directly by the scene not by the parent, and according to the documentation about boundingRect():

    QGraphicsView uses this to determine whether the item requires redrawing.

    So, if there is no drawing to do in the parent, there is no need to return a non-null bounding rectangle, even if the parent has child items. And if there is some drawing in the parent, it only needs to contain its own bounding rectangle.

提交回复
热议问题