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
Qt 6.11 is out! See what's new in the release blog

QPainterPathStroker outline problems

Scheduled Pinned Locked Moved Solved General and Desktop
qpainterpathoutlinestroker
2 Posts 2 Posters 774 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 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
    0
    • Q QtUser467

      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 last edited by
      #2

      Try QPainterPath::simplified()

      1 Reply Last reply
      0
      • Q QtUser467 has marked this topic as solved on

      • Login

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