QRectF boundingRect() const { qreal lx, rx, by, ty; lx =rx =by =ty =0; for(int i = 0; i < points.count() - 1; i++) { lx = qMin(lx, points[i].x()); rx = qMax(rx, points[i].x()); ty = qMax(ty, points[i].y()); by = qMin(by, points[i].y()); } return QRectF(lx, by, rx - lx, ty - by); }
C++ (Qt)inline QPointF MinPt( const QPointF & p1, const QPointF & p2 ){ return QPointF(qMin(p1.x(), p2.x()), qMin(p1.y(), p2.y()));} inline QPointF MaxPt( const QPointF & p1, const QPointF & p2 ){ return QPointF(qMax(p1.x(), p2.x()), qMax(p1.y(), p2.y()));} QRectF boundingRect() const{ int i, limit = points.count(); if (!limit) return QRectF(); QPointF lt, rb; LT = RB = points[0]; for (i = 1; i < limit; ++i) { lt = MinPt(lt, points[i]); rb = MaxPt(rb, points[i]); } return QRectF(lt, rb);}
C++ (Qt)void QGraphicsItem::prepareGeometryChange ()