#include#include int main(int argc, char *argv[]) { QApplication a(argc, argv); QPainterPath path; path.moveTo(10, 10); path.lineTo(50, 50); path.lineTo(90, 10); QPainter painter; painter.begin(&widget); painter.drawPath(path); painter.end(); return a.exec(); }
#includeIn this example, the lineTo function is used to draw straight lines to create a box shape, and then a curve is added to create a tail shape. The addPath function is used to combine the two QPainterPath objects into a single path, which is then drawn onto the widget using the QPainter object.#include int main(int argc, char *argv[]) { QApplication a(argc, argv); QPainterPath path; path.moveTo(10, 10); path.lineTo(10, 50); path.lineTo(50, 50); path.lineTo(50, 10); path.lineTo(10, 10); QPainterPath curve; curve.moveTo(10, 10); curve.lineTo(40, 30); curve.lineTo(10, 50); path.addPath(curve); QPainter painter; painter.begin(&widget); painter.drawPath(path); painter.end(); return a.exec(); }