Results 1 to 9 of 9

Thread: How to get points drawn by strokePath from outline of QPainterPath

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 879 Times in 827 Posts

    Default Re: How to get points drawn by strokePath from outline of QPainterPath

    Quote Originally Posted by userman View Post
    Uwe, you didn't get the point of this all... because you did not read my first post carefully.
    Well, there is QPainterPathStroker that is also internally used to create the QPainterPath that gets finally rendered.
    So what you need to do is to set up the stroker with the attributes of your pen and then the strokedPath can be read like in my previous posting.

    Thought you were talking about the strokedPath in your initial posting as you called it like that.

    Uwe

  2. The following user says thank you to Uwe for this useful post:

    userman (7th February 2018)

  3. #2
    Join Date
    Apr 2017
    Posts
    5
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: How to get points drawn by strokePath from outline of QPainterPath

    So the (other) final solution is:

    Draw along outline points of shape:
    qt-quest1.1.jpg

    Qt Code:
    1. QPainterPath path(QPointF(80, 320));
    2. path.lineTo(QPointF(240,90));
    3. path.lineTo(QPointF(330,240));
    4. path.lineTo(QPointF(620,180));
    5. path.lineTo(QPointF(730,110));
    6.  
    7. stroker.setCapStyle(Qt::RoundCap);
    8. stroker.setJoinStyle(Qt::RoundJoin);
    9. stroker.setWidth(100);
    10.  
    11. QPainterPath strokePath = stroker.createStroke(path).simplified();
    12.  
    13. for (int i = 0; i < strokePath.elementCount()-1; i++)
    14. {
    15. QPainterPath::Element p1 = strokePath.elementAt(i);
    16. QPainterPath::Element p2 = strokePath.elementAt(i+1);
    17. painter->setPen(QPen(i % 2 == 0 ? Qt::red : Qt::green, 1));
    18. painter->drawLine(QPointF(p1.x, p1.y), QPointF(p2.x, p2.y));
    19. }
    To copy to clipboard, switch view to plain text mode 

    Solved.

Similar Threads

  1. Adjusting QLineF points AFTER it has been drawn
    By bauervision in forum Qt Programming
    Replies: 0
    Last Post: 8th March 2017, 13:46
  2. How to draw strokepath
    By rajji_saini in forum Newbie
    Replies: 2
    Last Post: 5th April 2011, 01:11
  3. Remove unused points from a QPainterPath
    By JaV0 in forum Qt Programming
    Replies: 0
    Last Post: 4th March 2010, 08:35
  4. Remove points from a QPainterPath
    By JaV0 in forum Qt Programming
    Replies: 0
    Last Post: 3rd March 2010, 16:27
  5. Checking for intersect of QPainterPath OUTLINE?
    By SonOfGuest in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2009, 00: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
  •  
Qt is a trademark of The Qt Company.