Search code examples
c++qtcurve

How can I draw an open curve which is filled by a brush in Qt?


I'm programming in Qt and I need to draw a curve which is open and fill it with a brush color. I don't want it to be closed like a polygon. Considering my curve is a sinusoid, also I want to fill only the upper half of the curve (the parts above the X axis)


Solution

  • You can use QPainterPath, here is documentation link. QPainterPath has quadTo and cubicTo method which can draw curve.

    Documentation also has some nice example code which behaves as you are lookig for