I want to draw only the portion of the QPainter Curved Path. I have the path as this:
QPointF p[4];
p[0] = QPoint(100, 200);
p[1] = QPoint(200, 60);
p[2] = QPoint(500, 180);
p[3] = QPoint(600, 100);
cPath.cubicTo(p[1], -a*p[0] + p[1] + a*p[2], a*p[1] + p[2] -a*p[3], p[2]);
Now this draws the path as shown in the Fig 1.
But now I only want to draw the curve between the 2 points, let's say p(1) and p(2).
How can I draw only the portion of the bezier curve?
Here's how I solved this.
I used
QPainterPath::toSubpathPolygons
to return a list of polygons and got theQPolygonF
.Then I iterated over this
QPolygonF
and checked if the points in this polygon lie between the two points that I want. And then added those points to a new polygon.And now this polygon could be drawn with path.