I have a question about drawing specific arc on a scene. I have this information about arc:
Starting Koordinates,
Start Angle,
End Angle ,
Radius.
But I can’t use them efficently with QPainter. Actually I tried QPainterPath to use shape to show on QGraphicsScene with addPath("") but I can’t use function properly. My questions are about how to use this infortmation to draw arc and how to show it on my graphic scene.
You can use a
QGraphicsEllipseItemto add ellipses, circles, and segments/arcs to aQGraphicsScene.Try
Unfortunately, QGraphicsEllipseItem only supports
QPainter::drawEllipse()andQPainter::drawPie()– the latter can be used to draw arcs, but has the side effect that there is always a line drawn from the start and the end of the arc to the center.If you require a true arc, you can e.g. subclass
QGraphicsEllipseItemand override thepaint()method:You then still need to handle the item highlighting, unfortunately
qt_graphicsItem_highlightSelectedis a static function defined inside the Qt library.