|  | Home · Overviews · Examples |

# QPicture Class Reference
[com.trolltech.qt.gui module]

The `QPicture` class is a paint device that records and replays `QPainter` commands. More...

Inherits .

## Detailed Description

The `QPicture` class is a paint device that records and replays `QPainter` 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. 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.

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 the QPainter::begin() function.

Example of how to replay a picture:

                QPicture picture;
                picture.load("drawing.pic");           // load picture
                QPainter painter;
                painter.begin(&myWidget);              // paint in myWidget
                painter.drawPicture(0, 0, picture);    // draw the picture at (0,0)
                painter.end();                         // painting done

Pictures can also be drawn using `play`. Some basic data about a picture is available, for example, `size`, `isNull` and `boundingRect`.

See also `QMovie`.