PDA

View Full Version : Drawing a line on a QImage



Pritcher
31st March 2015, 16:02
I am trying to draw a line with penSize>=2 on a QImage . That is what I got:
11046

Here is how I do it

QPainter painter( getImage() );
QPen pen( getLeftColor(),
getPenSize(),
Qt::SolidLine,
Qt::SquareCap,
Qt::MiterJoin );
painter.setPen( pen );
if ( _startPoint == _endPoint )
painter.drawPoint( _endPoint );
else
painter.drawLine( _startPoint, _endPoint );
painter.end();

How can I fix this graphical artifact?

d_stranz
1st April 2015, 16:01
Here is how I do it

Oh really? There is nothing I can see in the fragment of code you have posted that will produce the effect shown in your screenshot. Your code draws either a line or a single point, not a series of jagged points.