// Creates a simple image
img.fill(Qt::transparent);
// Sets a pen with a width of 3 pixels
p.
setPen(QPen(QColor(255,
255,
0),
3, Qt
::SolidLine, Qt
::SquareCap, Qt
::BevelJoin));
// Draws the line
p.drawLine(50, 50, 100, 50);
// Saves the image
img.save("toto.png");
// Creates a simple image
QImage img(200, 200, QImage::Format_ARGB32_Premultiplied);
img.fill(Qt::transparent);
QPainter p(&img);
// Sets a pen with a width of 3 pixels
p.setPen(QPen(QColor(255, 255, 0), 3, Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));
// Draws the line
p.drawLine(50, 50, 100, 50);
// Saves the image
img.save("toto.png");
To copy to clipboard, switch view to plain text mode
Bookmarks