I'm new to posting on the forum but I've used it a lot.

I have an issue that I cant seem to find an answer on though.

My problem is that I have a number of points on a QGraphicsScene that are movable.

I want to be able to draw a curve that will pass through them. The thing is that the number of points is dynamic, can be 3 to a much larger number.
I have tried a QPainterPath, but I can only get straight lines between them.

I feel that someone will mention Bezier curves but I tried them. Unfortunately, it wont work for a couple of reasons:
1. The control point is not on the curve.
2. The curve will need to be more than one curve, it could be multiple "S" shapes strung together.

My attempt is below, I could be missing a flag from the QPainterPath to put a curve between the points but I'm struggling to find it:

Qt Code:
  1. QVector<QPointF> points;
  2. points << startPoint;
  3. for (int i=0; i<mHandles.size(); i++) {
  4. points << mHandles.at(i)->scenePos();
  5. }
  6. points << endPoint;
  8. QPainterPath testCurve;
  10. testCurve.addPolygon(QPolygonF(points));
  11. painter->drawPath(testCurve);
To copy to clipboard, switch view to plain text mode 

Any help would be greatly appreciated,
Thanks in advance