I am drawing an ellipse around a target. However the ellipses are not joined and elegant. By elegant I mean they are not smooth. this is what the ellipse around the image looks like
Notice the circle is not smooth and has roughness I would like to make it a smooth circle/ellipse. Any suggestions on how I could do that ? This is currently how I am doing the ellipses.
QPainter painter(target);
QPen pen;
pen.setColor(Qt::red);
pen.setWidth(4);
pen.setStyle( Qt::SolidLine);
pen.setCapStyle(Qt::SquareCap);
pen.setJoinStyle(Qt::BevelJoin);
painter.setPen(pen);
QRegion r(QRect(0, 0, 50, 50), QRegion::Ellipse);
painter.setClipRegion(r);
painter.drawPixmap(0, 0, source);
painter.drawEllipse(QRect(1, 1, 49, 49));
You need to enable antialiasing:
painter.setRenderHint(QPainter::Antialiasing);