Looking at the source code is a good way to answer your question (although J-P has already answered it a couple of times):
{
if (d->boundingRect.isNull()) {
qreal halfpw = pen().widthF() / 2;
d->boundingRect = d->rect;
if (halfpw > 0.0)
d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
}
return d->boundingRect;
}
QRectF QGraphicsRectItem::boundingRect() const
{
Q_D(const QGraphicsRectItem);
if (d->boundingRect.isNull()) {
qreal halfpw = pen().widthF() / 2;
d->boundingRect = d->rect;
if (halfpw > 0.0)
d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
}
return d->boundingRect;
}
To copy to clipboard, switch view to plain text mode
Especially take a look at line #6.
d->rect is set by QGraphicsRectItem::setRect().
Bookmarks