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. QPainterPath: strokeStart, strokeEnd

QPainterPath: strokeStart, strokeEnd

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 654 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.
  • P Offline
    P Offline
    pic.spencer
    wrote on last edited by
    #1

    I have a QPainterPath composed with arcTo, cubicTo, etc and maybe closed, maybe not. I want to stroke a section say from strokeStart at 0.2 to strokeEnd at 0.7. Can I do this?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pic.spencer
      wrote on last edited by pic.spencer
      #2

      Something like the following is probably my best option:

      auto start = 0.2f;
      auto end = 0.8f;
      auto resolution = 10;
      auto step = (end - start) / resolution;
      auto width = 8;
              
      QPainterPath masterPath = QPainterPath();
      masterPath.lineTo(boundingRect().size().width(), boundingRect().size().height());
      painter->strokePath(masterPath, QPen(Qt::black, width));
          
      QPainterPath shapePath = QPainterPath();
      shapePath.moveTo(masterPath.pointAtPercent(start));
              
      for (auto i = 0; i < resolution; i ++)
      {
           start += step;
           shapePath.lineTo(masterPath.pointAtPercent(start));
      }
      painter->strokePath(shapePath, QPen(Qt::cyan, width));
      
      1 Reply Last reply
      0

      • Login

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