How to understand Qt arcTo function

·

1 min read

void QPainterPath::arcTo(qreal x, qreal y, qreal width, qreal height, qreal startAngle, qreal sweepLength)

This function is used to construct a rectangular inner tangent circle with the given data and then display the image as needed. The startAngle and sweepLength are both angles, note that the angle is counterclockwise.

Draw a half circle

QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing);

const int radius = 300;
QPainterPath path;
path.moveTo(radius * 2, radius);
path.arcTo(0, 0, radius * 2, radius * 2, 0, 180);
painter.drawPath(path);

Draw a quarter circle

QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing);

const int radius = 300;
QPainterPath path;
path.moveTo(radius, 0);
path.arcTo(0, 0, radius * 2, radius * 2, 90, 90);
painter.drawPath(path);