Hi,
I got confused with the boundingRect. Since setRect sets the coodinate system of the corresponding item, what is boundingRect used for. I mean only setRect seems enough. What is the difference?
Regards
Hi,
I got confused with the boundingRect. Since setRect sets the coodinate system of the corresponding item, what is boundingRect used for. I mean only setRect seems enough. What is the difference?
Regards
But setRect() is not part of any QGraphicsItem but just QGraphicsRectItem (and QGraphicsEllipseItem) where it makes perfect sense.
J-P Nurmi
Hi again,
Yeah I mean QGraphicsRectItem or QGraphicsEllipseItem in which setRect method exists. But if we once make item.setRect(...), don't we already have a bounding rect?
Regards
More clearly;
For example, QGraphicsEllipseItem.setRect() = QGraphicsEllipseItem.boundingRect() ?
Regards
Looking at the source code is a good way to answer your question (although J-P has already answered it a couple of times):
Especially take a look at line #6.Qt Code:
{ 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
d->rect is set by QGraphicsRectItem::setRect().
Bookmarks