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

d->rect is set by QGraphicsRectItem::setRect().