Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved How can I create a "pie" using QGraphics.

    General and Desktop
    3
    3
    540
    Loading More Posts
    • 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.
    • A
      Alvaro.sal last edited by

      Hello forum, I want create a piece of pie using QGraphics, now I just get create a triangle but I need create a triangle with an arc (really a piece of pie). I saw an example using QPainter but my project is created using QGrapchics.

      Now I made an QPolygon:

      QPolygon triangle_s1;

      triangle_s1 << QPoint(0,0);
      triangle_s1 << QPoint(x1_s1,y_s1);
      triangle_s1 << QPoint(x2_s1,y_s1);
      triangle_s1 << QPoint(0,0);
      

      where x1_s1, x2_s1 and y_s1 are the coordinates for my triangle and I don't know how can I create the arc and paint inside my pie.

      So.. if somebody could help me I would very grateful.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        QGraphicsElipseItem comes to mind for that task.

        Hope it helps

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • Joel Bodenmann
          Joel Bodenmann last edited by

          Maybe this example might be helpful too: https://doc.qt.io/qt-5/qtwidgets-itemviews-chart-example.html
          It's not using QGraphics but it might help you figuring out some parts of the drawing logic or similar.

          Industrial process automation software: https://simulton.com
          Embedded Graphics & GUI library: https://ugfx.io

          1 Reply Last reply Reply Quote 0
          • First post
            Last post