Results 1 to 1 of 1

Thread: QPainterPath and drawing arc

  1. #1
    Join Date
    Feb 2010
    Location
    Russia, Omsk
    Posts
    28
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPainterPath and drawing arc

    I'm trying to draw a thick arc using QPainterPath

    Qt Code:
    1. QPainterPath* path = new QPainterPath();
    2. path->arcMoveTo(-innerWidth/2.0, -innerWidth/2.0, innerWidth, innerWidth, -45);
    3. // drawing the first (outer) arc from -45 to 225 degrees (counter-clockwise)
    4. path->arcTo(-innerWidth/2.0, -innerWidth/2.0, innerWidth, innerWidth, -45, 270);
    5. path->arcMoveTo(-innerWidth/2.0 + gradientPartThickness, -innerWidth/2.0 + gradientPartThickness, innerWidth - gradientPartThickness*2, innerWidth - gradientPartThickness*2, 225);
    6. // drawing the second (inner) arc from 225 to -45 degrees (clockwise)
    7. path->arcTo(-innerWidth/2.0 + gradientPartThickness, -innerWidth/2.0 + gradientPartThickness, innerWidth - gradientPartThickness*2, innerWidth - gradientPartThickness*2, 225, -270);
    8. path->lineTo(gradientTopRight); // line up to the first arc
    9. path->closeSubpath();
    10. QLinearGradient gradient(innerRect.topLeft(), innerRect.topRight());
    11. gradient.setColorAt(0, Qt::white);
    12. gradient.setColorAt(1, Qt::red);
    13. painter.fillPath(*path, QBrush(gradient));
    To copy to clipboard, switch view to plain text mode 

    But what I actually get is here
    http://screencast.com/t/Li1dtXc3

    Can anybody help please?


    Added after 42 minutes:


    Solved
    instead of
    Qt Code:
    1. path->arcMoveTo(-innerWidth/2.0 + gradientPartThickness, -innerWidth/2.0 + gradientPartThickness, innerWidth - gradientPartThickness*2, innerWidth - gradientPartThickness*2, 225);
    To copy to clipboard, switch view to plain text mode 
    wrote
    Qt Code:
    1. entirePath->lineTo(gradientBottomLeft);
    To copy to clipboard, switch view to plain text mode 
    Last edited by Annihilator; 6th July 2013 at 19:15.

Similar Threads

  1. QPainterPath -
    By aguleo in forum Newbie
    Replies: 4
    Last Post: 17th February 2013, 17:47
  2. Replies: 1
    Last Post: 13th December 2011, 18:28
  3. QPainterPath::quadTo(...) calls QPainterPath::cubicTo(...) ?
    By brucelamond in forum Qt Programming
    Replies: 0
    Last Post: 29th April 2011, 00:30
  4. Advices for animating drawing of a QPainterPath?
    By Gnurou in forum Qt Programming
    Replies: 0
    Last Post: 4th July 2008, 16:17
  5. QPainterPath drawing problem
    By shad in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2007, 14:30

Tags for this Thread

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.