#includeQPainter painter(this); QPolygonF points({{10, 10}, {100, 10}, {100, 100}, {10, 100}}); painter.drawPolygon(points);
#includeThis example creates a QPainter object and draws an irregular polygon with four manually defined points. The points are defined using QPointF objects and then passed to the drawPolygon function of the painter to draw them on the widget. Package Library: Qt is a popular open-source C++ GUI framework used for developing cross-platform applications. The QPainter class is part of the Qt GUI library. Therefore, you need to include the QtGui header file and link to the QtGui library when using QPainter in your project.QPainter painter(this); QPolygonF points; points << QPointF(0, 0) << QPointF(100, 0) << QPointF(50, 75) << QPointF(0, 50); painter.drawPolygon(points);