Qt学习笔记(十一)基本图案绘制

1、测试代码

void MyDrawWindow::paintEvent(QPaintEvent *event) {
    int width = this->width();
    int height = this->height();
    QPainter painter(this);
    QColor color(0, 0, 265);
    QPen pen(color);
    QBrush brush(QColor(255, 0, 0));
    painter.setPen(pen);
    painter.setBrush(brush);

    painter.drawRect(20, 20, 50, 90);
    painter.drawEllipse(QPoint(width/2,height/2),20,20);
    painter.drawLine(QPoint(80,80),QPoint(100,100));
}

效果图


image.png

你可能感兴趣的:(Qt学习笔记(十一)基本图案绘制)