Qt QPainterPath

作用

为painter设置好绘画路径

成员函数

painter.drawPath()

1,使用当前笔画轮廓;

2,填充path指定的路径绘画出来的图形。

xxx.to()

lineTo()

Qt QPainterPath_第1张图片

 Qt QPainterPath_第2张图片

moveTo()

使用path作画,一定要先将path的启动移动到需要开始绘画的点,否则默认从

(0,0)开始作画。 

Qt QPainterPath_第3张图片

Qt QPainterPath_第4张图片 

 

    QPainter painter(this);

    QPen pen;
    pen.setColor(QColor(128,0,0));
    pen.setWidth(2);
    painter.setPen(pen);

    painter.setRenderHint(QPainter::HighQualityAntialiasing);
    QPainterPath path;
    //path.addEllipse(QRect(10,10,30,50));
    //path.lineTo(30,30);
    painter.drawEllipse(QPoint(100,100),50,25);//point(center)坐标是矩形的中心

    path.moveTo(100,100);//将画笔移动到矩形的中心
    path.arcTo(QRect(50,75,100,50),90,90);//50--x,75--y;这个不是矩形的中心,而是矩形左上角
    painter.setBrush(QBrush("green"));
    painter.drawPath(path);


 

你可能感兴趣的:(qt,数学建模,开发语言)