1、绘制渐变轨迹
paintEvent中:
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
QConicalGradient gradient;
gradient.setCenter(rect.center());
gradient.setAngle(-90);
gradient.setColorAt(0, QColor(154, 175, 248));
gradient.setColorAt(1, QColor(48, 82, 202));
QPen pen(QBrush(gradient), m_pensize);
pen.setCapStyle(Qt::RoundCap);
painter.setPen(pen);
painter.drawArc(rect, (m_start_angle) * 16, (m_end_angle) * 16);
效果:
其实单独实现渐变绘图是很简单的,但是是在弧上绘制渐变,网上很多方式不能用