【例】:
QPen pen;
pen.setBrush(Qt::red) //设置画刷颜色
pen.setWidth(10); //设置宽度
pen.setStyle(Qt::SolidLine); //设置画笔风格
pen.setCapStyle(Qt::FlatCap); //画笔端点风格
pen.setJoinStyle(Qt::BevelJoin); //画笔连接风格
painter.setPen(pen); //设置画笔给画家
QRect rect (10,20,80,60);
painter.drawRoundedRect(rect , 25 , 25 , Qt::RelativeSize); //画一个圆角矩形
画刷设置
【例】:
QBrush brush;
brush.setColor(Qt::blue);
brush.setStyle(Qt::Dense3Pattern);
painter.setBrush(brush);
渐变填充:
//线性渐变:
QLinearGradient linearGra(QPointF(10,20) , QPointF(90,80));
linearGra.setColorAt(0 , Qt::yellow);
linearGra.setColorAt(0.5 , Qt::blue);
linearGra.setColorAt(1 , Qt::yellow);
painter.setBrush(linearGra);
//辐射渐变
QRadialGradient
//锥形渐变
QConicalGradient