#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);
}