Qt绘图设备QPicture

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

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

    /* 绘图设备 可以记录和重现绘图指令 */
    QPicture picture;
    QPainter painter;
    painter.begin(&picture);
    painter.setPen(Qt::red);
    painter.drawEllipse(QPoint(100, 100), 50, 50);
    painter.end();
    picture.save("D:\\picture.fr");
}

void Widget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    /* 重现picture */
    QPicture picture;
    picture.load("D:\\picture.fr");
    painter.drawPicture(0, 0, picture);
}

posted @   thomas_blog  阅读(59)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
点击右上角即可分享
微信分享提示