QPicture Class Reference

[QtGui module]

该QPicture类是一个绘图设备,记录和重放QPainter的命令。More…

继承QPaintDevice

Methods

  • __init__ (self, int formatVersion = -1)
  • __init__ (self, QPicture)
  • QRect boundingRect (self)
  • str data (self)
  • detach (self)
  • int devType (self)
  • bool isDetached (self)
  • bool isNull (self)
  • bool load (self, QIODevice dev, str format = None)
  • bool load (self, QString fileName, str format = None)
  • int metric (self, QPaintDevice.PaintDeviceMetric m)
  • QPaintEngine paintEngine (self)
  • bool play (self, QPainter p)
  • bool save (self, QIODevice dev, str format = None)
  • bool save (self, QString fileName, str format = None)
  • setBoundingRect (self, QRect r)
  • setData (self, str data)
  • int size (self)
  • swap (self, QPicture other)

Static Methods

  • QStringList inputFormatList ()
  • list-of-QByteArray inputFormats ()
  • QStringList outputFormatList ()
  • list-of-QByteArray outputFormats ()
  • str pictureFormat (QString fileName)

Detailed Description

该QPicture类是一个绘图设备,记录和重放QPainter的命令。

的图片序列画家命令IO设备在一个平台无关的格式。它们有时被称为元文件。

Qt的图片用一个专有的二进制格式。不像本地图片(元文件)在许多窗口系统格式, Qt的图片有关于他们的内容没有限制。所有可以被画上一个小部件或像素(例如,字体,像素图,区域,变换图形等)也可以被存储在一个图像。

QPicture是与分辨率无关,即QPicture可以显示在不同的设备(例如SVG , PDF,PS ,打印机和屏幕)寻找相同。这是,例如,需要所见即所得的打印预览。 QPicture运行在默认的系统DPI ,并缩放画家,以符合视视窗系统上的分辨率的差异。

如何进行拍摄的例子:

  1. QPicture picture;
  2. [QPainter]($docs-qpainter.html) painter;
  3. painter.begin(&picture); // paint in picture
  4. painter.drawEllipse(10,20, 80,70); // draw an ellipse
  5. painter.end(); // painting done
  6. picture.save("drawing.pic"); // save picture

需要注意的是画家的命令列表被重置在每次调用QPainter.begin()函数。

如何重播图片的例子:

  1. QPicture picture;
  2. picture.load("drawing.pic"); // load picture
  3. [QPainter]($docs-qpainter.html) painter;
  4. painter.begin(&myImage); // paint in myImage
  5. painter.drawPicture(0, 0, picture); // draw the picture at (0,0)
  6. painter.end(); // painting done

图片也可以使用拉伸play( ) 。关于一个图像的一些基本数据是可用的,例如,size( )isNull()和boundingRect( ) 。


Method Documentation

  1. QPicture.__init__ (self, int formatVersion = -1)

构造一个空的图片。

formatVersion参数可以被用于createQPicture可以由与Qt的早期版本编译的应用程序可以读取。

请注意,默认formatVersion是-1,表示当前版本,即Qt的4.0 7 formatVersion是一样的为默认值-1 formatVersion 。

是不是在Qt的4.0支持Qt的早期版本生成的读图时代。

  1. QPicture.__init__ (self, QPicture)

构造的副本pic

这个构造函数是快的感谢implicit sharing

  1. QRect QPicture.boundingRect (self)

[

返回图片的边界矩形或无效矩形如果图片不包含任何数据。

]($docs-qrect.html)

See also setBoundingRect( ) 。

  1. str QPicture.data (self)

返回一个指向图片数据。指针才有效,直到下一个非const函数被调用的这张图片。返回的指针为0,如果图像不包含任何数据。

See also setData( )size()和isNull( ) 。

  1. QPicture.detach (self)
  1. int QPicture.devType (self)
  1. QStringList QPicture.inputFormatList ()
  1. list-of-QByteArray QPicture.inputFormats ()
  1. bool QPicture.isDetached (self)
  1. bool QPicture.isNull (self)

返回True如果图像不包含任何数据,否则返回False 。

  1. bool QPicture.load (self, QIODevice dev, str format = None)

加载一幅图片从指定的文件fileName如果成功返回True,否则返回False 。

请注意,这个format参数已被取代,不会有任何效果。

See also save( ) 。

  1. bool QPicture.load (self, QString fileName, str format = None)

这是一个重载函数。

dev是该装置用于载入。

  1. int QPicture.metric (self, QPaintDevice.PaintDeviceMetric m)
  1. QStringList QPicture.outputFormatList ()
  1. list-of-QByteArray QPicture.outputFormats ()
  1. QPaintEngine QPicture.paintEngine (self)

[

  1. str QPicture.pictureFormat (QString fileName)
  1. bool QPicture.play (self, QPainter p)

重播的画面使用painter,并成功返回True ,否则返回False 。

]($docs-qpaintengine.html)

这个函数完全一样QPainter.drawPicture( )与(X,Y )=(0 ,0)。

  1. bool QPicture.save (self, QIODevice dev, str format = None)

保存图片到由指定的文件fileName如果成功返回True,否则返回False 。

请注意,这个format参数已被取代,不会有任何效果。

See also load( ) 。

  1. bool QPicture.save (self, QString fileName, str format = None)

这是一个重载函数。

dev是设备用于储蓄。

  1. QPicture.setBoundingRect (self, QRect r)

设置图片的边界矩形r。自动计算的值被复盖。

See also boundingRect( ) 。

  1. QPicture.setData (self, str data)

直接将画面设置数据datasize。此功能将输入数据复制。

See also data()和size( ) 。

  1. int QPicture.size (self)

返回的图片数据的大小。

See also data( ) 。

  1. QPicture.swap (self, QPicture other)

掉期图片other与此图片。这个操作是非常快的,而且永远不会。

此功能被引入Qt的4.8 。