Take the 2-minute tour ×

I am trying to draw an ellipse in Qt and the border on the edges goes thin in some places.

enter image description here

Here is the code:

QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, 3));

Any ideas? Thanks in advance.

share|improve this question

1 Answer 1

When painting a shape with an outline, you have to factor in the width of the pen. So in your case, change to this:

// Adjusted by 2 pixels because half your pen width is 1.5, but QRect is
// for integer types, so rounded up.
painter.drawEllipse(event->rect().adjusted( -2, -2, 2, 2 ) );
share|improve this answer

Your Answer


