Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
The Maximum Number of Control Points to Draw a Bezier Curve with QPainterPath
I've drawn the bezier curve by using QPainterPath as following. The initial control point (C0, start point) is set with the function moveTo. The control points C1, C2 and the last control point (C4, end point) are set with the function cubicTo. Is the maximum number of control points is 4 to create bezier curve with QPainterPath? If not, could you please explain how to draw a bezier curve with 6 control points?
mCurrentPath.cubicTo(40, 10, 50, 50, 199, 199);
Thanks a lot for your explanations and helps,
I want to learn the Qt's limitations related to bezier curves. I suppose QtSDK does not include a function to draw higher-degree (>4) bezier curves, doesn't it?
Thanks in advance
Have you tried to "compose":https://qt-project.org/doc/qt-4.8/qpainterpath.html#composing-a-qpainterpath different painter paths ? This way you could construct bezier splines with a higher degree.
For example you could first draw a spline using the first 4 points (A,B,C,D) then draw a second spline using points B,C,D,E and so on. Depending on the combination of points you use to compose the splines you get different results.
I guess you're familiar with the "theoretics":http://en.wikipedia.org/wiki/Bézier_curve for splines?
Thanks a lot for your help,
I've tried to compose the different painter paths for example fifth degree bezier curve (five control points). But the result is the composition of several curves. Whereas I've expected only one curve composing of five control points. I've read the wiki article but I can't figure out how to draw higher degree bezier curves by using QPainterPath.
Can QPainterPath succeed it? Otherwise should I try external library (Qwt) or write myself? I will be so glad if you can explain.
mCurrentPath.cubicTo(Q_NODE_POINT(1), Q_NODE_POINT(2), Q_NODE_POINT(3));
mPath.cubicTo(Q_NODE_POINT(2), Q_NODE_POINT(3), Q_NODE_POINT(4));
The idea of composing the PainterPaths was just a guess, you could also try it with quadratic Bezier curves. If there isn't an easy way to achieve your desired functionality this way, I don't think it would make much sense to write something yourself, as splines are a common thing and there should be solutions for this ready for use. If you know any external library that offers the features you are looking for I'd suggest you use that. I'm only familiar with the theoretics from my time at the university, but I haven't used it in Qt by now. Sorry but I can't offer any more...
I just got another idea how you might be able to make this work using PainterPaths. QPainterPath has a method pointAtPercent(). You could use this to compose the PainterPaths. Paint the first PainterPath till t 0.5 or something then paint the second PainterPath starting at t 0.5. Take a look at how the curves in "this section of the wiki article":http://en.wikipedia.org/wiki/Bézier_curve#Higher-order_curves are drawn this might give you a better idea of what i mean.