Qt绘图设备QImage

#include "widget.h"
#include "ui_widget.h"
#include <QPainter>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    /* 绘图设备 */
    QImage img(300, 300, QImage::Format_RGB32);
    img.fill(Qt::lightGray);

    QPainter painter(&img);
    painter.setPen(QPen(Qt::red));
    painter.drawEllipse(QPoint(100, 100), 50, 50);

    ui->label->setPixmap(QPixmap::fromImage(img));
}

posted @ 2022-08-05 13:28  thomas_blog  阅读(48)  评论(0编辑  收藏  举报