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. QPainterPathStroker outline problems
QtWS25 Last Chance

QPainterPathStroker outline problems

Scheduled Pinned Locked Moved Solved General and Desktop
qpainterpathoutlinestroker
2 Posts 2 Posters 256 Views
  • 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.
  • Q Offline
    Q Offline
    QtUser467
    wrote on 29 Apr 2024, 11:14 last edited by
    #1

    I use QPainterPathStroker to get the outline of a path. The path is composed of multiple straight segments.
    When I paint it with a wide pen, I get this:

    s1.png

    When I produce an outline with QPainterPathStroker with the following code...

        QPainterPath p;
        p.moveTo(_xy_path.first());
        for (const auto& pt : _xy_path.path())
            p.lineTo(pt);
    
        QPainterPathStroker ps;
        ps.setWidth(_pen.widthF() + dist);
        ps.setCapStyle(Qt::RoundCap);
        ps.setJoinStyle(Qt::RoundJoin);
        return ps.createStroke(p);
    

    and plot the outline, I get this:

    s2.png

    Obviously, the "loops" towards the inside of the shape are not what I want. How can these be eliminated?

    M 1 Reply Last reply 29 Apr 2024, 14:21
    0
    • Q QtUser467
      29 Apr 2024, 11:14

      I use QPainterPathStroker to get the outline of a path. The path is composed of multiple straight segments.
      When I paint it with a wide pen, I get this:

      s1.png

      When I produce an outline with QPainterPathStroker with the following code...

          QPainterPath p;
          p.moveTo(_xy_path.first());
          for (const auto& pt : _xy_path.path())
              p.lineTo(pt);
      
          QPainterPathStroker ps;
          ps.setWidth(_pen.widthF() + dist);
          ps.setCapStyle(Qt::RoundCap);
          ps.setJoinStyle(Qt::RoundJoin);
          return ps.createStroke(p);
      

      and plot the outline, I get this:

      s2.png

      Obviously, the "loops" towards the inside of the shape are not what I want. How can these be eliminated?

      M Offline
      M Offline
      medyakovvit
      wrote on 29 Apr 2024, 14:21 last edited by
      #2

      Try QPainterPath::simplified()

      1 Reply Last reply
      0
      • Q QtUser467 has marked this topic as solved on 30 Apr 2024, 19:03

      1/2

      29 Apr 2024, 11:14

      • Login

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