Qt学习 第23节:QPen 和 QBrush

本文详细介绍了Qt库中QPainter和QPen类的应用,讲解了如何设置线条样式、宽度、颜色以及连接和端点风格。通过实例展示了不同笔刷风格在图形绘制中的效果,如实线、虚线、点线等,并强调了QBrush在填充形状中的作用。
摘要由CSDN通过智能技术生成

strokes :(铅笔、刷子的)一笔,一挥,笔画 ,
n.击球(动作);(打、击等的)一下,一击;划水动作;划桨动作
v.轻抚,抚摩(动物的毛皮);抚摩(物体表面或头发等);轻挪;轻触;轻拭

 The pen style defines the line type. The brush is used to fill strokes generated with the pen

 QPainter painter(this);
 QPen pen(Qt::green, 3, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin);
 painter.setPen(pen);
which is equivalent to
 QPainter painter(this);
 QPen pen;  // creates a default pen

 pen.setStyle(Qt::DashDotLine);
 pen.setWidth(3);
 pen.setBrush(Qt::green);
 pen.setCapStyle(Qt::RoundCap);
 pen.setJoinStyle(Qt::RoundJoin);

 painter.setPen(pen);

The QPen class defines how a QPainter should draw lines and outlines of shapes. 

 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().

 The QBrush class defines the fill pattern of shapes drawn by QPainter

Qt::BrushStyle 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值