1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/image/qpicture.cpp -->
7
<title>Qt 4.0: QPicture Class Reference</title>
8
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
9
a:link { color: #004faf; text-decoration: none }
10
a:visited { color: #672967; text-decoration: none }
11
td.postheader { font-family: sans-serif }
12
tr.address { font-family: sans-serif }
13
body { background: #ffffff; color: black; }</style>
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
19
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QPicture Class Reference</h1>
21
<p>The QPicture class is a paint device that records and replays <a href="qpainter.html">QPainter</a> commands. <a href="#details">More...</a></p>
22
<pre>#include <QPicture></pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
23
<p>Inherits <a href="qpaintdevice.html">QPaintDevice</a>.</p>
24
<p>Inherited by <a href="q3picture.html">Q3Picture</a>.</p>
26
<li><a href="qpicture-members.html">List of all members, including inherited members</a></li>
27
<li><a href="qpicture-qt3.html">Qt 3 support members</a></li>
29
<a name="public-functions"></a>
30
<h3>Public Functions</h3>
32
<li><div class="fn"/><b><a href="qpicture.html#QPicture">QPicture</a></b> ( int <i>formatVersion</i> = -1 )</li>
33
<li><div class="fn"/><b><a href="qpicture.html#QPicture-2">QPicture</a></b> ( const QPicture & <i>pic</i> )</li>
34
<li><div class="fn"/><b><a href="qpicture.html#dtor.QPicture">~QPicture</a></b> ()</li>
35
<li><div class="fn"/>QRect <b><a href="qpicture.html#boundingRect">boundingRect</a></b> () const</li>
36
<li><div class="fn"/>const char * <b><a href="qpicture.html#data">data</a></b> () const</li>
37
<li><div class="fn"/>bool <b><a href="qpicture.html#isNull">isNull</a></b> () const</li>
38
<li><div class="fn"/>bool <b><a href="qpicture.html#load">load</a></b> ( const QString & <i>fileName</i>, const char * <i>format</i> = 0 )</li>
39
<li><div class="fn"/>bool <b><a href="qpicture.html#load-2">load</a></b> ( QIODevice * <i>dev</i>, const char * <i>format</i> = 0 )</li>
40
<li><div class="fn"/>bool <b><a href="qpicture.html#play">play</a></b> ( QPainter * <i>painter</i> )</li>
41
<li><div class="fn"/>bool <b><a href="qpicture.html#save">save</a></b> ( const QString & <i>fileName</i>, const char * <i>format</i> = 0 )</li>
42
<li><div class="fn"/>bool <b><a href="qpicture.html#save-2">save</a></b> ( QIODevice * <i>dev</i>, const char * <i>format</i> = 0 )</li>
43
<li><div class="fn"/>void <b><a href="qpicture.html#setBoundingRect">setBoundingRect</a></b> ( const QRect & <i>r</i> )</li>
44
<li><div class="fn"/>virtual void <b><a href="qpicture.html#setData">setData</a></b> ( const char * <i>data</i>, uint <i>size</i> )</li>
45
<li><div class="fn"/>uint <b><a href="qpicture.html#size">size</a></b> () const</li>
46
<li><div class="fn"/>QPicture & <b><a href="qpicture.html#operator-eq">operator=</a></b> ( const QPicture & <i>p</i> )</li>
49
<li><div class="fn"/>10 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
51
<a name="static-public-members"></a>
52
<h3>Static Public Members</h3>
54
<li><div class="fn"/>QStringList <b><a href="qpicture.html#inputFormatList">inputFormatList</a></b> ()</li>
55
<li><div class="fn"/>QList<QByteArray> <b><a href="qpicture.html#inputFormats">inputFormats</a></b> ()</li>
56
<li><div class="fn"/>QStringList <b><a href="qpicture.html#outputFormatList">outputFormatList</a></b> ()</li>
57
<li><div class="fn"/>QList<QByteArray> <b><a href="qpicture.html#outputFormats">outputFormats</a></b> ()</li>
58
<li><div class="fn"/>const char * <b><a href="qpicture.html#pictureFormat">pictureFormat</a></b> ( const QString & <i>fileName</i> )</li>
60
<a name="protected-functions"></a>
61
<h3>Protected Functions</h3>
63
<li><div class="fn"/>virtual int <b><a href="qpicture.html#metric">metric</a></b> ( PaintDeviceMetric <i>m</i> ) const</li>
65
<a name="related-non-members"></a>
66
<h3>Related Non-Members</h3>
68
<li><div class="fn"/>QDataStream & <b><a href="qpicture.html#operator-lt-lt-56">operator<<</a></b> ( QDataStream & <i>s</i>, const QPicture & <i>r</i> )</li>
69
<li><div class="fn"/>QDataStream & <b><a href="qpicture.html#operator-gt-gt-36">operator>></a></b> ( QDataStream & <i>s</i>, QPicture & <i>r</i> )</li>
71
<a name="details"></a>
73
<h2>Detailed Description</h2>
74
<p>The QPicture class is a paint device that records and replays <a href="qpainter.html">QPainter</a> commands.</p>
75
<p>A picture serializes painter commands to an IO device in a platform-independent format. They are sometimes referred to as meta-files.</p>
76
<p>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 an <a href="shclass.html">implicitly shared</a> class.</p>
77
<p>Example of how to record a picture:</p>
78
<p>printuntil save</p>
79
<p>Example of how to replay a picture:</p>
80
<pre> QPicture picture;
81
picture.load("drawing.pic"); // load picture
83
painter.begin(&myWidget); // paint in myWidget
84
painter.drawPicture(0, 0, picture); // draw the picture at (0,0)
85
painter.end(); // painting done</pre>
86
<p>Pictures can also be drawn using <a href="qpicture.html#play">play</a>(). Some basic data about a picture is available, for example, <a href="qpicture.html#size">size</a>(), <a href="qpicture.html#isNull">isNull</a>() and <a href="qpicture.html#boundingRect">boundingRect</a>().</p>
88
<h2>Member Function Documentation</h2>
89
<h3 class="fn"><a name="QPicture"></a>QPicture::QPicture ( int <i>formatVersion</i> = -1 )</h3>
90
<p>Constructs an empty picture.</p>
91
<p>The <i>formatVersion</i> parameter may be used to <i>create</i> a <a href="qpicture.html">QPicture</a> that can be read by applications that are compiled with earlier versions of Qt.</p>
92
<p>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.</p>
93
<p>Reading pictures generated by earlier versions of Qt is not supported in Qt 4.0.</p>
94
<h3 class="fn"><a name="QPicture-2"></a>QPicture::QPicture ( const QPicture & <i>pic</i> )</h3>
95
<p>Constructs a <a href="shclass.html">shallow copy</a> of <i>pic</i>.</p>
96
<h3 class="fn"><a name="dtor.QPicture"></a>QPicture::~QPicture ()</h3>
97
<p>Destroys the picture.</p>
98
<h3 class="fn"><a name="boundingRect"></a><a href="qrect.html">QRect</a> QPicture::boundingRect () const</h3>
99
<p>Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data.</p>
100
<h3 class="fn"><a name="data"></a>const char * QPicture::data () const</h3>
101
<p>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.</p>
102
<p>See also <a href="qpicture.html#size">size</a>() and <a href="qpicture.html#isNull">isNull</a>().</p>
103
<h3 class="fn"><a name="inputFormatList"></a><a href="qstringlist.html">QStringList</a> QPicture::inputFormatList () <tt> [static]</tt></h3>
104
<p>Returns a list of picture formats that are supported for picture input.</p>
105
<p>Note that if you want to iterate over the list, you should iterate over a copy, e.g.</p>
106
<pre> QStringList list = myPicture.inputFormatList();
107
foreach (QString string, list)
108
myProcessing(string);</pre>
109
<p>See also <a href="qpicture.html#outputFormatList">outputFormatList</a>(), <a href="qpicture.html#inputFormats">inputFormats</a>(), and <a href="qpictureio.html">QPictureIO</a>.</p>
110
<h3 class="fn"><a name="inputFormats"></a><a href="qlist.html">QList</a><<a href="qbytearray.html">QByteArray</a>> QPicture::inputFormats () <tt> [static]</tt></h3>
111
<p>Returns a list of picture formats that are supported for picture input.</p>
112
<p>See also <a href="qpicture.html#outputFormats">outputFormats</a>(), <a href="qpicture.html#inputFormatList">inputFormatList</a>(), and <a href="qpictureio.html">QPictureIO</a>.</p>
113
<h3 class="fn"><a name="isNull"></a>bool QPicture::isNull () const</h3>
114
<p>Returns true if the picture contains no data; otherwise returns false.</p>
115
<h3 class="fn"><a name="load"></a>bool QPicture::load ( const <a href="qstring.html">QString</a> & <i>fileName</i>, const char * <i>format</i> = 0 )</h3>
116
<p>Loads a picture from the file specified by <i>fileName</i> and returns true if successful; otherwise returns false.</p>
117
<p>By default, the file will be interpreted as being in the native <a href="qpicture.html">QPicture</a> format. Specifying the <i>format</i> string is optional and is only needed for importing picture data stored in a different format.</p>
118
<p>See also <a href="qpicture.html#save">save</a>().</p>
119
<h3 class="fn"><a name="load-2"></a>bool QPicture::load ( <a href="qiodevice.html">QIODevice</a> * <i>dev</i>, const char * <i>format</i> = 0 )</h3>
120
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
121
<p><i>dev</i> is the device to use for loading.</p>
122
<h3 class="fn"><a name="metric"></a>int QPicture::metric ( <a href="qpaintdevice.html#PaintDeviceMetric-enum">PaintDeviceMetric</a> <i>m</i> ) const <tt> [virtual protected]</tt></h3>
123
<p>Internal implementation of the virtual <a href="qpaintdevice.html#metric">QPaintDevice::metric</a>() function.</p>
124
<p>A picture has the following hard-coded values: dpi=72, numcolors=16777216 and depth=24.</p>
125
<p><i>m</i> is the metric to get.</p>
126
<p>Reimplemented from <a href="qpaintdevice.html#metric">QPaintDevice</a>.</p>
127
<h3 class="fn"><a name="outputFormatList"></a><a href="qstringlist.html">QStringList</a> QPicture::outputFormatList () <tt> [static]</tt></h3>
128
<p>Returns a list of picture formats that are supported for picture output.</p>
129
<p>Note that if you want to iterate over the list, you should iterate over a copy, e.g.</p>
130
<pre> QStringList list = myPicture.outputFormatList();
131
foreach (QString string, list)
132
myProcessing(string);</pre>
133
<p>See also <a href="qpicture.html#inputFormatList">inputFormatList</a>(), <a href="qpicture.html#outputFormats">outputFormats</a>(), and <a href="qpictureio.html">QPictureIO</a>.</p>
134
<h3 class="fn"><a name="outputFormats"></a><a href="qlist.html">QList</a><<a href="qbytearray.html">QByteArray</a>> QPicture::outputFormats () <tt> [static]</tt></h3>
135
<p>Returns a list of picture formats that are supported for picture output.</p>
136
<p>See also <a href="qpicture.html#inputFormats">inputFormats</a>(), <a href="qpicture.html#outputFormatList">outputFormatList</a>(), and <a href="qpictureio.html">QPictureIO</a>.</p>
137
<h3 class="fn"><a name="pictureFormat"></a>const char * QPicture::pictureFormat ( const <a href="qstring.html">QString</a> & <i>fileName</i> ) <tt> [static]</tt></h3>
138
<p>Returns a string that specifies the picture format of the file <i>fileName</i>, or 0 if the file cannot be read or if the format is not recognized.</p>
139
<p>The <a href="qpictureio.html">QPictureIO</a> documentation lists the guaranteed supported picture formats, or use <a href="qpicture.html#inputFormats">QPicture::inputFormats</a>() and <a href="qpicture.html#outputFormats">QPicture::outputFormats</a>() to get lists that include the installed formats.</p>
140
<p>See also <a href="qpicture.html#load">load</a>() and <a href="qpicture.html#save">save</a>().</p>
141
<h3 class="fn"><a name="play"></a>bool QPicture::play ( <a href="qpainter.html">QPainter</a> * <i>painter</i> )</h3>
142
<p>Replays the picture using <i>painter</i>, and returns true if successful; otherwise returns false.</p>
143
<p>This function does exactly the same as <a href="qpainter.html#drawPicture">QPainter::drawPicture</a>() with (x, y) = (0, 0).</p>
144
<h3 class="fn"><a name="save"></a>bool QPicture::save ( const <a href="qstring.html">QString</a> & <i>fileName</i>, const char * <i>format</i> = 0 )</h3>
145
<p>Saves a picture to the file specified by <i>fileName</i> and returns true if successful; otherwise returns false.</p>
146
<p>Specifying the file <i>format</i> string is optional. By default the data will be saved in the native <a href="qpicture.html">QPicture</a> file format.</p>
147
<p>See also <a href="qpicture.html#load">load</a>().</p>
148
<h3 class="fn"><a name="save-2"></a>bool QPicture::save ( <a href="qiodevice.html">QIODevice</a> * <i>dev</i>, const char * <i>format</i> = 0 )</h3>
149
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
150
<p><i>dev</i> is the device to use for saving.</p>
151
<h3 class="fn"><a name="setBoundingRect"></a>void QPicture::setBoundingRect ( const <a href="qrect.html">QRect</a> & <i>r</i> )</h3>
152
<p>Sets the picture's bounding rectangle to <i>r</i>. The automatically calculated value is overridden.</p>
153
<h3 class="fn"><a name="setData"></a>void QPicture::setData ( const char * <i>data</i>, <a href="qtglobal.html#uint-typedef">uint</a> <i>size</i> ) <tt> [virtual]</tt></h3>
154
<p>Sets the picture data directly from <i>data</i> and <i>size</i>. This function copies the input data.</p>
155
<p>See also <a href="qpicture.html#data">data</a>() and <a href="qpicture.html#size">size</a>().</p>
156
<h3 class="fn"><a name="size"></a><a href="qtglobal.html#uint-typedef">uint</a> QPicture::size () const</h3>
157
<p>Returns the size of the picture data.</p>
158
<p>See also <a href="qpicture.html#data">data</a>().</p>
159
<h3 class="fn"><a name="operator-eq"></a>QPicture & QPicture::operator= ( const QPicture & <i>p</i> )</h3>
160
<p>Assigns picture <i>p</i> to this picture and returns a reference to this picture.</p>
162
<h2>Related Non-Members</h2>
163
<h3 class="fn"><a name="operator-lt-lt-56"></a><a href="qdatastream.html">QDataStream</a> & operator<< ( <a href="qdatastream.html">QDataStream</a> & <i>s</i>, const QPicture & <i>r</i> )</h3>
164
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
165
<p>Writes picture <i>r</i> to the stream <i>s</i> and returns a reference to the stream.</p>
166
<h3 class="fn"><a name="operator-gt-gt-36"></a><a href="qdatastream.html">QDataStream</a> & operator>> ( <a href="qdatastream.html">QDataStream</a> & <i>s</i>, QPicture & <i>r</i> )</h3>
167
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
168
<p>Reads a picture from the stream <i>s</i> into picture <i>r</i> and returns a reference to the stream.</p>
169
<p /><address><hr /><div align="center">
170
<table width="100%" cellspacing="0" border="0"><tr class="address">
171
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
172
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
173
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
174
</tr></table></div></address></body>