QPen画笔

QPen用户绘图时对线条进行设置,包括线宽、颜色、线型等。

void setColor(const QColor &color)设置画笔颜色,即线条颜色
void setWidth(int width)

设置线条宽度

void setStyle(Qt::PenStyle)设置线条样式
void setCapStyle(Qt::PenCapStyle pcs)设置线条端点样式
void setJoinStyle(Qt::PenJoinStyle pcs)设置连接样式

1. 线条样式:Qt::PenStyle

Qt::NoPen0no line at all. For example, QPainter::drawRect() fills but does not draw any boundary line.
Qt::SolidLine1A plain line.
Qt::DashLine2Dashes separated by a few pixels.
Qt::DotLine3Dots separated by a few pixels.
Qt::DashDotLine4Alternate dots and dashes.
Qt::DashDotDotLine5One dash, two dots, one dash, two dots.
Qt::CustomDashLine6A custom pattern defined using QPainterPathStroker::setDashPattern().

除上述几种基本线条样式外,可以自定义线条样式,自定义线条样式时需要用到setDashOffset()和setDashPattern()函数。

2. 线条端点样式:Qt::PenCapStyle

Qt::FlatCap0x00不包含最后一个点
Qt::SquareCap0x10是一种包含了最后一个点的方形端点,使用半个线宽覆盖
Qt::RoundCap0x20是包含最后一个点的圆形端点

 

3. 线条连接样式:Qt::PenJoinStyle

Qt::MiterJoin0x00The outer edges of the lines are extended to meet at an angle, and this area is filled.
Qt::BevelJoin0x40The triangular notch between the two lines is filled.
Qt::RoundJoin0x80A circular arc between the two lines is filled.

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值