参考资料:

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);

}

 

posted on 2018-12-19 20:19  邶风  阅读(2037)  评论(0编辑  收藏  举报