三角函数cos和sin画圆
void Widget::paintEvent(QPaintEvent *)
{
QPainter painter(this); // 创建QPainter一个对象
QPen pen;
// 画多个点
int x=0, y=0, r=200;
int center_x=300, center_y=300;
pen.setWidth(1);
painter.setPen(pen);
for (int i = 0; i < 360; i++) {
x=cos(i*(3.14/180))*r+center_x;
y=sin(i*(3.14/180))*r+center_y;
painter.drawPoint(x, y);
}
}
实际效果