
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQPicture class is a paint device that records and replaysQPainter commands.More...
| Header: | #include <QPicture> |
| Inherits: | QPaintDevice |
| Inherited By: |
| 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 = 0) |
| bool | load(QIODevice * dev, const char * format = 0) |
| bool | play(QPainter * painter) |
| bool | save(const QString & fileName, const char * format = 0) |
| bool | save(QIODevice * dev, const char * format = 0) |
| 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) |
TheQPicture class is a paint device that records and replaysQPainter commands.
A picture serializes painter commands to an IO device in a platform-independent format. They are sometimes referred to as meta-files.
Qt pictures use a proprietary binary format. Unlike native picture (meta-file) formats on many window systems, Qt pictures have no limitations regarding their contents. Everything that can be painted on a widget or pixmap (e.g., fonts, pixmaps, regions, transformed graphics, etc.) can also be stored in a picture.
QPicture is resolution independent, i.e. aQPicture 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.
Example of how to record a picture:
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
Note that the list of painter commands is reset on each call to theQPainter::begin() function.
Example of how to replay a picture:
QPicture picture; picture.load("drawing.pic");// load pictureQPainter painter; painter.begin(&myImage);// paint in myImage painter.drawPicture(0,0, picture);// draw the picture at (0,0) painter.end();// painting done
Pictures can also be drawn usingplay(). Some basic data about a picture is available, for example,size(),isNull() andboundingRect().
See alsoQMovie.
Constructs an empty picture.
TheformatVersion parameter may be used tocreate aQPicture 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.
Constructs a copy ofpic.
This constructor is fast thanks toimplicit sharing.
Destroys the picture.
Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data.
See alsosetBoundingRect().
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.
See alsosetData(),size(), andisNull().
Returns true if the picture contains no data; otherwise returns false.
Loads a picture from the file specified byfileName and returns true if successful; otherwise returns false.
Please note that theformat parameter has been deprecated and will have no effect.
See alsosave().
This is an overloaded function.
dev is the device to use for loading.
Replays the picture usingpainter, and returns true if successful; otherwise returns false.
This function does exactly the same asQPainter::drawPicture() with (x, y) = (0, 0).
Saves a picture to the file specified byfileName and returns true if successful; otherwise returns false.
Please note that theformat parameter has been deprecated and will have no effect.
See alsoload().
This is an overloaded function.
dev is the device to use for saving.
Sets the picture's bounding rectangle tor. The automatically calculated value is overridden.
See alsoboundingRect().
[virtual]void QPicture::setData(constchar * data,uint size)Sets the picture data directly fromdata andsize. This function copies the input data.
Returns the size of the picture data.
See alsodata().
Swaps pictureother with this picture. This operation is very fast and never fails.
This function was introduced in Qt 4.8.
Assigns picturep to this picture and returns a reference to this picture.
Writes picturer to the streams and returns a reference to the stream.
Reads a picture from the streams into picturer and returns a reference to the stream.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.