Qt: 绘图基础

Qt: 绘图基础
QPainter 能绘制: point, line, rectangle, ellipse, arc, chord, polygon, pie segment, Bezier curve, QPixmap, QImge
Qt支持的高级特性: antialising, alpha blending, gradient fill, vector path.
QPainter在什么上绘制呢? 在"paint device": QWidget, QPixmap, QImage, QSvgGenerator, 连接QPrinter来打印和生成PDF文档.

通常在protected void paintEvent(QPaintEvent *event)中进行绘制.
protected  :
    virtual 
void  paintEvent(QPaintEvent  * event) {
        QPainter painter(
this );  //  Pointer of the paint device
        ..
    }

QPainter的3个主要设置是: pen, brush, font.
painter.setPen(QPen(..));
painter.setBruch(QBrush(..));
painter.setFont(QFont(..));
painter.setRenderHint(QPainter::Antialiasing, true);
设置了bursh之后, 画的是效果即fill.
QPainter的属性影响绘制的图形.

通常使用painter.paintXXX(..)来绘制图形.

你可能感兴趣的:(Qt: 绘图基础)