//1
QPainter painter(this);
QColor color;
color.setRgb(85,0,127);
painter.setPen(color);
//2
QPen pen(QColor(124, 122, 121,200));
pen.setWidth(4);
painter.setPen(pen);
//3
pen.setColor("orange");
pen.setWidth(4);
painter.setPen(pen);
//4
painter.setPen(QColor("#1E90FF"));
//给矩形框填充颜色
QRect r2(ppos, QSize(200, 220));
painter.fillRect(r2,QColor(203,203,203,50));
//填充圆颜色
painter.setBrush(QBrush(QColor(249, 109, 59)));
painter.setPen(Qt::NoPen);//设置是否有边框
painter.drawEllipse(c,14,14);
//画弧线
painter.setPen(pen);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.drawArc(rectangle, 0, -180 * 16);//三点钟方向为0
//冲rectangle里面内切椭圆 从0开始 取-180度 通过调整rectangle的长宽改变弧度大小
There are several ways to set colors in qpainter. Fill the rectangle with color, fill the circle with color and remove the border, and draw arcs with qt.
Guess you like
Origin blog.csdn.net/qq_30727593/article/details/130764181
Recommended
Ranking