Sébastien
7th July 2013, 16:01
Hello,
I'm having some trouble just to draw a single horizontal line with a QPainter. The following code and its output are self-explanatory:
// 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");
The foo.png image generated does have a an horizontal line, but with a width of 2 pixels instead of 3.
I guess this is a bug, as I clearly don't see what I've done wrong. I had this issue on my program I'm working on, in which I had lines with the wrong width... Then I wrote this simple code just to check. And it looks like a Qt bug. What do you think? Is this a known issue? I'm using Qt 5.0.2 with gcc 4.7.2 on Windows 8.
Thanks!
I'm having some trouble just to draw a single horizontal line with a QPainter. The following code and its output are self-explanatory:
// 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");
The foo.png image generated does have a an horizontal line, but with a width of 2 pixels instead of 3.
I guess this is a bug, as I clearly don't see what I've done wrong. I had this issue on my program I'm working on, in which I had lines with the wrong width... Then I wrote this simple code just to check. And it looks like a Qt bug. What do you think? Is this a known issue? I'm using Qt 5.0.2 with gcc 4.7.2 on Windows 8.
Thanks!