Important: Please read the Qt Code of Conduct -

(SOLVED) Draw arc into qgraphicsview

  • I have:
    Graphicsview dove;
    Graphicsscene scene;
    if I want to draw an ellipse can do(and circle)
    if I want to draw an rectangle can do
    But if I want to draw an arc as I do?
    dove.scene.addarc not exist.

  • You can create a QGraphicsPathItem, and set a QPainterPath that contains the arc you want to draw (use QPainterPath::moveTo and QPainterPath::arcTo)

  • I tried but does not work as I would like;
    I would use drawArc of QPainter;
    Someone could tell me how can I do?

  • You can always create your own QGraphicsItem: Derive from QGraphicsItem, and implement paint and boundingRect.

  • I solved this way:
    @ QPicture pi;
    QPainter p(&pi);
    p.setPen(QPen(Qt::black, 1));

    where dove is a QLabels

  • You could use the same approach with a QPixmap and a QGraphicsPixmapItem. But if your current approach works well for you, that's certainly ok.

Log in to reply