#include <QtGui>
int main()
{
polygon<<QPointF(-10.0,-10.0);
polygon<<QPointF(-5.0,10.0);
polygon<<QPointF(0.0,5.0);
polygon<<QPointF(5,-10.0);
image.fill(Qt::transparent);
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::red);
painter.translate(180,180);
painter.drawPolygon(polygon);
image.save("test.png");
}
#include <QtGui>
int main()
{
QPolygonF polygon;
polygon<<QPointF(-10.0,-10.0);
polygon<<QPointF(-5.0,10.0);
polygon<<QPointF(0.0,5.0);
polygon<<QPointF(5,-10.0);
QImage image(360, 360, QImage::Format_ARGB32);
image.fill(Qt::transparent);
QPainter painter(&image);
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::red);
painter.translate(180,180);
painter.drawPolygon(polygon);
image.save("test.png");
}
To copy to clipboard, switch view to plain text mode
It works the same with QPixmap.
Bookmarks