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

2018-04-22  本文已影响0人  行走行囊

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
上一篇下一篇

猜你喜欢

热点阅读