谷歌搜索 suggests that it should .
但是拖放机器人 example implementation (在父 Robot 对象上)建议不要:
QRectF Robot::boundingRect() const
{
return QRectF();
}
哪个是正确的,还是有更微妙的事情发生?
最佳答案
子项由场景直接绘制,而不是由父项绘制,并根据 the documentation about boundingRect()
:
QGraphicsView uses this to determine whether the item requires redrawing.
因此,如果父项中没有要绘制的内容,则无需返回非空边界矩形,即使父项中有子项也是如此。 如果父级中有一些绘图,它只需要包含自己的边界矩形。
关于c++ - QGraphicsItem::boundingRect() 是否应该包含子边界矩形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7448321/