参考资料:
https://www.cnblogs.com/Jace-Lee/p/5946342.html
效果图:
代码:
void WgtText::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
QPen pen; // creates a default pen
pen.setStyle(Qt::DashDotLine);
pen.setWidth(3);
pen.setBrush(Qt::blue);
pen.setCapStyle(Qt::RoundCap);
pen.setJoinStyle(Qt::RoundJoin);
painter.setPen(pen);
QPointF point_start(10,10);
QPointF point_end(300, 400);
painter.drawLine(point_start, point_end);
}