QPicture 类是描绘设备,它记录并重演 QPainter 命令。 更多...
头: | #include <QPicture> |
qmake: | QT += gui |
继承: | QPaintDevice |
QPicture (int formatVersion = -1) | |
QPicture (const QPicture & pic ) | |
~QPicture () | |
QRect | boundingRect () const |
const char * | data () const |
bool | isNull () const |
bool | load (const QString & fileName , const char * format = Q_NULLPTR) |
bool | load (QIODevice * dev , const char * format = Q_NULLPTR) |
bool | play (QPainter * painter ) |
bool | save (const QString & fileName , const char * format = Q_NULLPTR) |
bool | save (QIODevice * dev , const char * format = Q_NULLPTR) |
void | setBoundingRect (const QRect & r ) |
virtual void | setData (const char * data , uint size ) |
uint | size () const |
void | swap (QPicture & other ) |
QPicture & | operator= (const QPicture & p ) |
QPicture & | operator= (QPicture && other ) |
QDataStream & | operator<< (QDataStream & s , const QPicture & r ) |
QDataStream & | operator>> (QDataStream & s , QPicture & r ) |
QPicture 类是描绘设备,它记录并重演 QPainter 命令。
图片以独立于平台的格式将描绘器命令序列化到 IO 设备。它们有时被称为元文件。
QPicture 使用专有二进制格式。不像很多窗口系统中的本机图片 (元文件) 格式,QPicture 在其内容方面没有局限性。可以在 Widget 或像素图中绘制一切 (如:字体、像素图、区域、变换图形、等),也可以存储在图片中。
QPicture is resolution independent, i.e. a QPicture can be displayed on different devices (for example svg, pdf, ps, printer and screen) looking the same. This is, for instance, needed for WYSIWYG print preview. QPicture runs in the default system dpi, and scales the painter to match differences in resolution depending on the window system.
如何录制图片的范例:
QPicture picture; QPainter painter; painter.begin(&picture); // paint in picture painter.drawEllipse(10,20, 80,70); // draw an ellipse painter.end(); // painting done picture.save("drawing.pic"); // save picture
注意,描绘器命令列表会被重置当每次调用 QPainter::begin () 函数。
如何重演图片的范例:
QPicture picture; picture.load("drawing.pic"); // load picture QPainter painter; painter.begin(&myImage); // paint in myImage painter.drawPicture(0, 0, picture); // draw the picture at (0,0) painter.end(); // painting done
也可以绘制图片使用 play ()。关于图片的一些基本数据是可用的,例如, size (), isNull () 和 boundingRect ().
另请参阅 QMovie .
构造空图片。
formatVersion parameter may be used to create a QPicture that can be read by applications that are compiled with earlier versions of Qt.
Note that the default formatVersion is -1 which signifies the current release, i.e. for Qt 4.0 a formatVersion of 7 is the same as the default formatVersion of -1.
Reading pictures generated by earlier versions of Qt is not supported in Qt 4.0.
构造副本为 pic .
此构造函数很快感谢 隐式共享 .
销毁图片。
Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data.
另请参阅 setBoundingRect ().
Returns a pointer to the picture data. The pointer is only valid until the next non-const function is called on this picture. The returned pointer is 0 if the picture contains no data.
另请参阅 setData (), size (),和 isNull ().
返回
true
if the picture contains no data; otherwise returns false.
Loads a picture from the file specified by
fileName
and returns true if successful; otherwise invalidates the picture and returns
false
.
Please note that the format parameter has been deprecated and will have no effect.
另请参阅 save ().
这是重载函数。
dev 是用于加载的设备。
重演图片使用
painter
,并返回
true
若成功;否则返回
false
.
此函数做的准确如同 QPainter::drawPicture () 采用 (x, y) = (0, 0)。
Saves a picture to the file specified by
fileName
and returns true if successful; otherwise returns
false
.
Please note that the format parameter has been deprecated and will have no effect.
另请参阅 load ().
这是重载函数。
dev 是用于保存的设备。
Sets the picture's bounding rectangle to r . The automatically calculated value is overridden.
另请参阅 boundingRect ().
[virtual]
void
QPicture::
setData
(const
char
*
data
,
uint
size
)
Sets the picture data directly from data and size . This function copies the input data.
返回图片数据的大小。
另请参阅 data ().
Swaps picture other with this picture. This operation is very fast and never fails.
该函数在 Qt 4.8 引入。
赋值图片 p to this picture and returns a reference to this picture.
移动赋值 other 到此 QPicture 实例。
该函数在 Qt 5.2 引入。
写入图片 r 到流 s 并返回流引用。
Reads a picture from the stream s into picture r 并返回流引用。