例如:这是qt的源代码里的关于QGraphicsLineItem::boundingRect()
QRectF QGraphicsLineItem::boundingRect() const
{
Q_D(const QGraphicsLineItem);
if (d->pen.widthF() == 0.0) {
const qreal x1 = d->line.p1().x();
const qreal x2 = d->line.p2().x();
const qreal y1 = d->line.p1().y();
const qreal y2 = d->line.p2().y();
qreal lx = qMin(x1, x2);
qreal rx = qMax(x1, x2);
qreal ty = qMin(y1, y2);
qreal by = qMax(y1, y2);
return QRectF(lx, ty, rx - lx, by - ty);
}
return shape().controlPointRect();
}
当我先中这个直线的时候,会出来他的外包框(一个矩形),但现在我不想要显示这个矩形,应该怎么才能做到呢?谢谢各位朋友
还有一个问题,下面这个是qt源代码中的 QGraphicsPolygonItem::shape()
QPainterPath QGraphicsPolygonItem::shape() const
{
Q_D(const QGraphicsPolygonItem);
QPainterPath path;
path.addPolygon(d->polygon);
return qt_graphicsItem_shapeFromPath(path, d->pen);
}
当我生成一个不闭合的多拆线时,例如:a->b->c->d.这个shape的QPainterPath好像是a->b->c->d->a,我想要的是a->b->c->d.请问如何才能做到啊,谢谢各位朋友,大家相互学习啊