Results 1 to 3 of 3

Thread: QPainterPath

  1. #1
    Join Date
    Jun 2013
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QPainterPath

    Hi everybody!

    I'm new in this forum and I hope you can help me.

    I would like to draw a 3d pie slice with QPainterPath. See the SourceCode.

    Qt Code:
    1. QPainter paint(this);
    2.  
    3. paint.setRenderHint(QPainter::Antialiasing,true);
    4. paint.translate(width()/2, height()/2);
    5.  
    6. paint.setBrush(QColor(0,255,0,127));
    7.  
    8. QPainterPath paint4;
    9.  
    10. paint4.setFillRule(Qt::WindingFill);
    11. paint4.moveTo(300,150);
    12. paint4.arcTo(0,0,600,300,10,45);
    13. paint4.lineTo(300,150);
    14.  
    15.  
    16. paint4.lineTo(300,180);
    17. paint4.arcTo(0,30,600,300,10,45);
    18. paint4.lineTo(300,180);
    19.  
    20.  
    21. int xw2 = 300 * cos(55*(M_PI/180));
    22. int yw2 = -150 * sin(55*(M_PI/180));
    23. xw2+=300;
    24. yw2+=150;
    25.  
    26. QPainterPath paint5;
    27. paint5.moveTo(xw2,yw2);
    28. paint5.lineTo(xw2,yw2+30);
    29. paint4.addPath(paint5);
    30.  
    31.  
    32. int xw = 300 * cos(10*(M_PI/180));
    33. int yw = -150 * sin(10*(M_PI/180));
    34. xw+=300;
    35. yw+=150;
    36.  
    37. QPainterPath paint6;
    38.  
    39. paint6.moveTo(xw,yw);
    40. paint6.lineTo(xw,yw+30);
    41. paint4.addPath(paint6);
    42.  
    43.  
    44. paint.drawPath(paint4);
    To copy to clipboard, switch view to plain text mode 

    Unfortunately, I can't fill the sides of the pie slice with the given color.

    Thank you for your help in advance.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QPainterPath

    Qt Code:
    1. QPainterPath paint7;
    2.  
    3. paint7.moveTo(300,150);
    4. paint7.lineTo(xw,yw);
    5. paint7.lineTo(xw,yw+30);
    6. paint7.lineTo(300,180);
    7. paint7.lineTo(300,150);
    8. paint4.addPath(paint7);
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jun 2013
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QPainterPath

    Thanks a lot!

Similar Threads

  1. QPainterPath -
    By aguleo in forum Newbie
    Replies: 4
    Last Post: 17th February 2013, 16:47
  2. QPainterPath::quadTo(...) calls QPainterPath::cubicTo(...) ?
    By brucelamond in forum Qt Programming
    Replies: 0
    Last Post: 28th April 2011, 23:30
  3. QPainterPath and scale()
    By edwardc in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2010, 10:03
  4. QPainterPath and QPolygon
    By Muz in forum Qt Programming
    Replies: 0
    Last Post: 18th September 2009, 07:16
  5. QPainterPath.arcTo
    By grellsworth in forum Qt Programming
    Replies: 1
    Last Post: 18th March 2008, 17:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.