Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. (SOLVED) Draw arc into qgraphicsview
Qt 6.11 is out! See what's new in the release blog

(SOLVED) Draw arc into qgraphicsview

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 5.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Asperamanca
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            I solved this way:
            @ QPicture pi;
            QPainter p(&pi);
            p.setRenderHint(QPainter::Antialiasing);
            p.setPen(QPen(Qt::black, 1));
            p.drawLine(x1,y1,x2,y2);
            p.end();
            dove->setPicture(pi);
            @

            where dove is a QLabels

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Asperamanca
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved