QPainter绘制 保存图片

来源:互联网 发布:mac连蓝牙耳机 编辑:程序博客网 时间:2024/04/29 04:06

代码 :

    QPainter p(this);    QPixmap map(width, height);    map.fill(Qt::transparent);    p.begin(&map);    //p.setTransform(ma);    p.drawRect(QRect(0, 0, 100, 100));//绘制    p.end();    map.save("C:/Users/Administrator/Desktop/123.png", "PNG");//保存


步骤:

1.实例化QPainter 和 QPixmap;

2.在把painter 设置绘制在 pixmap 上(用begin()函数);

3.然后绘制更新painter ;

4.绘制结束(end()),保存pixmap图像;

0 0