我正在尝试跟踪场景中某个扇区的路径。
QGraphicsEllipseItem *sector = new QGraphicsEllipseItem;
sector->setSpanAngle(5*16); //the span angle here is 5 degrees
sector->setStartAngle(startAngle*16);
然后将其放在qGraphicsScene
上,一切都很好。现在出于碰撞检测的目的,我正在使用QPainterPathStroker
。但是作为一个测试,我想检查一下它用这么粗的笔shape()
画出的路径,就像这样......
QPen blackPen(Qt::black, 15); //Thick pen, just because
QPainterPath path = QPainterPath(sector->shape());
this->scene->addPath(path,blackPen);
我期待的是一个跨度角大约为5度的扇形的蓝色轮廓。相反,我得到一个奇怪的L形状的东西。
Pic of what I'm trying to explain...
(忽略中间的水平线)
你可以看到扇形的虚线轮廓,有一个非常粗的蓝色笔,应该跟踪破折号。我已经有一段时间了,但无济于事。有解决方案吗?
编辑:我想通了。我在closeSubpath()
上使用了QPainterPath
。
答案 0 :(得分:1)
我明白了。我在closeSubpath()
上使用了QPainterPath
。