source: trunk/doc/html/qsize.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 18.5 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qsize.cpp:42 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QSize Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QSize Class Reference</h1>
33
34<p>The QSize class defines the size of a two-dimensional object.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qsize-h.html">qsize.h</a>&gt;</tt>
37<p><a href="qsize-members.html">List of all member functions.</a>
38<h2>Public Members</h2>
39<ul>
40<li class=fn>enum <a href="#ScaleMode-enum"><b>ScaleMode</b></a> { ScaleFree, ScaleMin, ScaleMax }</li>
41<li class=fn><a href="#QSize"><b>QSize</b></a> ()</li>
42<li class=fn><a href="#QSize-2"><b>QSize</b></a> ( int&nbsp;w, int&nbsp;h )</li>
43<li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
44<li class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</li>
45<li class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</li>
46<li class=fn>int <a href="#width"><b>width</b></a> () const</li>
47<li class=fn>int <a href="#height"><b>height</b></a> () const</li>
48<li class=fn>void <a href="#setWidth"><b>setWidth</b></a> ( int&nbsp;w )</li>
49<li class=fn>void <a href="#setHeight"><b>setHeight</b></a> ( int&nbsp;h )</li>
50<li class=fn>void <a href="#transpose"><b>transpose</b></a> ()</li>
51<li class=fn>void <a href="#scale"><b>scale</b></a> ( int&nbsp;w, int&nbsp;h, ScaleMode&nbsp;mode )</li>
52<li class=fn>void <a href="#scale-2"><b>scale</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;s, ScaleMode&nbsp;mode )</li>
53<li class=fn>QSize <a href="#expandedTo"><b>expandedTo</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;otherSize ) const</li>
54<li class=fn>QSize <a href="#boundedTo"><b>boundedTo</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;otherSize ) const</li>
55<li class=fn>QCOORD &amp; <a href="#rwidth"><b>rwidth</b></a> ()</li>
56<li class=fn>QCOORD &amp; <a href="#rheight"><b>rheight</b></a> ()</li>
57<li class=fn>QSize &amp; <a href="#operator+-eq"><b>operator+=</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;s )</li>
58<li class=fn>QSize &amp; <a href="#operator--eq"><b>operator-=</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;s )</li>
59<li class=fn>QSize &amp; <a href="#operator*-eq"><b>operator*=</b></a> ( int&nbsp;c )</li>
60<li class=fn>QSize &amp; <a href="#operator*-eq-2"><b>operator*=</b></a> ( double&nbsp;c )</li>
61<li class=fn>QSize &amp; <a href="#operator/-eq"><b>operator/=</b></a> ( int&nbsp;c )</li>
62<li class=fn>QSize &amp; <a href="#operator/-eq-2"><b>operator/=</b></a> ( double&nbsp;c )</li>
63</ul>
64<h2>Related Functions</h2>
65<ul>
66<li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;s1, const&nbsp;QSize&nbsp;&amp;&nbsp;s2 )</li>
67<li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;s1, const&nbsp;QSize&nbsp;&amp;&nbsp;s2 )</li>
68<li class=fn>const QSize <a href="#operator+"><b>operator+</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;s1, const&nbsp;QSize&nbsp;&amp;&nbsp;s2 )</li>
69<li class=fn>const QSize <a href="#operator-"><b>operator-</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;s1, const&nbsp;QSize&nbsp;&amp;&nbsp;s2 )</li>
70<li class=fn>const QSize <a href="#operator*"><b>operator*</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;s, int&nbsp;c )</li>
71<li class=fn>const QSize <a href="#operator*-2"><b>operator*</b></a> ( int&nbsp;c, const&nbsp;QSize&nbsp;&amp;&nbsp;s )</li>
72<li class=fn>const QSize <a href="#operator*-3"><b>operator*</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;s, double&nbsp;c )</li>
73<li class=fn>const QSize <a href="#operator*-4"><b>operator*</b></a> ( double&nbsp;c, const&nbsp;QSize&nbsp;&amp;&nbsp;s )</li>
74<li class=fn>const QSize <a href="#operator/"><b>operator/</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;s, int&nbsp;c )</li>
75<li class=fn>const QSize <a href="#operator/-2"><b>operator/</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;s, double&nbsp;c )</li>
76<li class=fn>QDataStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, const&nbsp;QSize&nbsp;&amp;&nbsp;sz )</li>
77<li class=fn>QDataStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, QSize&nbsp;&amp;&nbsp;sz )</li>
78</ul>
79<hr><a name="details"></a><h2>Detailed Description</h2>
80
81
82The QSize class defines the size of a two-dimensional object.
83<p>
84
85<p> A size is specified by a width and a height.
86<p> The coordinate type is QCOORD (defined in <tt>&lt;qwindowdefs.h&gt;</tt> as <tt>int</tt>).
87The minimum value of QCOORD is QCOORD_MIN (-2147483648) and the maximum
88value is QCOORD_MAX (2147483647).
89<p> The size can be set in the constructor and changed with <a href="#setWidth">setWidth</a>()
90and <a href="#setHeight">setHeight</a>(), or using <a href="#operator+-eq">operator+=</a>(), <a href="#operator--eq">operator-=</a>(), <a href="#operator*-eq">operator*=</a>()
91and <a href="#operator/-eq">operator/=</a>(), etc. You can swap the width and height with
92<a href="#transpose">transpose</a>(). You can get a size which holds the maximum height and
93width of two sizes using <a href="#expandedTo">expandedTo</a>(), and the minimum height and
94width of two sizes using <a href="#boundedTo">boundedTo</a>().
95<p> <p>See also <a href="qpoint.html">QPoint</a>, <a href="qrect.html">QRect</a>, <a href="graphics.html">Graphics Classes</a>, and <a href="images.html">Image Processing Classes</a>.
96
97<hr><h2>Member Type Documentation</h2>
98<h3 class=fn><a name="ScaleMode-enum"></a>QSize::ScaleMode</h3>
99<p> This enum type defines the different ways of scaling a size.
100<p> <center><img src="scaling.png"></center>
101<ul>
102<li><tt>QSize::ScaleFree</tt> - The size is scaled freely. The ratio is not preserved.
103<li><tt>QSize::ScaleMin</tt> - The size is scaled to a rectangle as large as possible
104inside a given rectangle, preserving the aspect ratio.
105<li><tt>QSize::ScaleMax</tt> - The size is scaled to a rectangle as small as possible
106outside a given rectangle, preserving the aspect ratio.
107</ul><p> <p>See also <a href="#scale">QSize::scale</a>(), <a href="qimage.html#scale">QImage::scale</a>(), and <a href="qimage.html#smoothScale">QImage::smoothScale</a>().
108
109<hr><h2>Member Function Documentation</h2>
110<h3 class=fn><a name="QSize"></a>QSize::QSize ()
111</h3>
112
113Constructs a size with invalid (negative) width and height.
114
115<h3 class=fn><a name="QSize-2"></a>QSize::QSize ( int&nbsp;w, int&nbsp;h )
116</h3>
117
118Constructs a size with width <em>w</em> and height <em>h</em>.
119
120<h3 class=fn><a href="qsize.html">QSize</a> <a name="boundedTo"></a>QSize::boundedTo ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;otherSize ) const
121</h3>
122
123<p> Returns a size with the minimum width and height of this size and
124<em>otherSize</em>.
125
126<h3 class=fn><a href="qsize.html">QSize</a> <a name="expandedTo"></a>QSize::expandedTo ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;otherSize ) const
127</h3>
128
129<p> Returns a size with the maximum width and height of this size and
130<em>otherSize</em>.
131
132<p>Examples: <a href="customlayout-example.html#x1528">customlayout/card.cpp</a> and <a href="customlayout-example.html#x1485">customlayout/flow.cpp</a>.
133<h3 class=fn>int <a name="height"></a>QSize::height () const
134</h3>
135
136Returns the height.
137<p>See also <a href="#width">width</a>().
138
139<p>Examples: <a href="movies-example.html#x520">movies/main.cpp</a>, <a href="qfd-example.html#x2007">qfd/fontdisplayer.cpp</a>, and <a href="qfd-example.html#x2016">qfd/qfd.cpp</a>.
140<h3 class=fn>bool <a name="isEmpty"></a>QSize::isEmpty () const
141</h3>
142
143Returns TRUE if the width is less than or equal to 0, or the height is
144less than or equal to 0; otherwise returns FALSE.
145
146<h3 class=fn>bool <a name="isNull"></a>QSize::isNull () const
147</h3>
148
149Returns TRUE if the width is 0 and the height is 0; otherwise
150returns FALSE.
151
152<h3 class=fn>bool <a name="isValid"></a>QSize::isValid () const
153</h3>
154
155Returns TRUE if the width is equal to or greater than 0 and the height is
156equal to or greater than 0; otherwise returns FALSE.
157
158<h3 class=fn><a href="qsize.html">QSize</a>&nbsp;&amp; <a name="operator*-eq"></a>QSize::operator*= ( int&nbsp;c )
159</h3>
160
161Multiplies both the width and height by <em>c</em> and returns a reference to
162the size.
163
164<h3 class=fn><a href="qsize.html">QSize</a>&nbsp;&amp; <a name="operator*-eq-2"></a>QSize::operator*= ( double&nbsp;c )
165</h3>
166This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
167<p> Multiplies both the width and height by <em>c</em> and returns a reference to
168the size.
169<p> Note that the result is truncated.
170
171<h3 class=fn><a href="qsize.html">QSize</a>&nbsp;&amp; <a name="operator+-eq"></a>QSize::operator+= ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s )
172</h3>
173
174<p> Adds <em>s</em> to the size and returns a reference to this size.
175<p> Example:
176<pre>
177 QSize s( 3, 7 );
178 QSize r( -1, 4 );
179 s += r; // s becomes (2,11)
180</pre>
181
182
183<h3 class=fn><a href="qsize.html">QSize</a>&nbsp;&amp; <a name="operator--eq"></a>QSize::operator-= ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s )
184</h3>
185
186<p> Subtracts <em>s</em> from the size and returns a reference to this size.
187<p> Example:
188<pre>
189 QSize s( 3, 7 );
190 QSize r( -1, 4 );
191 s -= r; // s becomes (4,3)
192 </pre>
193
194
195<h3 class=fn><a href="qsize.html">QSize</a>&nbsp;&amp; <a name="operator/-eq"></a>QSize::operator/= ( int&nbsp;c )
196</h3>
197
198Divides both the width and height by <em>c</em> and returns a reference to the
199size.
200
201<h3 class=fn><a href="qsize.html">QSize</a>&nbsp;&amp; <a name="operator/-eq-2"></a>QSize::operator/= ( double&nbsp;c )
202</h3>
203
204This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
205<p> Divides both the width and height by <em>c</em> and returns a reference to the
206size.
207<p> Note that the result is truncated.
208
209<h3 class=fn>QCOORD &amp; <a name="rheight"></a>QSize::rheight ()
210</h3>
211
212Returns a reference to the height.
213<p> Using a reference makes it possible to directly manipulate the height.
214<p> Example:
215<pre>
216 QSize s( 100, 10 );
217 s.<a href="#rheight">rheight</a>() += 5; // s becomes (100,15)
218 </pre>
219
220<p> <p>See also <a href="#rwidth">rwidth</a>().
221
222<h3 class=fn>QCOORD &amp; <a name="rwidth"></a>QSize::rwidth ()
223</h3>
224
225Returns a reference to the width.
226<p> Using a reference makes it possible to directly manipulate the width.
227<p> Example:
228<pre>
229 QSize s( 100, 10 );
230 s.<a href="#rwidth">rwidth</a>() += 20; // s becomes (120,10)
231 </pre>
232
233<p> <p>See also <a href="#rheight">rheight</a>().
234
235<h3 class=fn>void <a name="scale"></a>QSize::scale ( int&nbsp;w, int&nbsp;h, <a href="qsize.html#ScaleMode-enum">ScaleMode</a>&nbsp;mode )
236</h3>
237Scales the size to a rectangle of width <em>w</em> and height <em>h</em> according
238to the ScaleMode <em>mode</em>.
239<p> <ul>
240<li> If <em>mode</em> is <a href="#ScaleMode-enum">ScaleFree</a>, the size is set to (<em>w</em>, <em>h</em>).
241<li> If <em>mode</em> is <a href="#ScaleMode-enum">ScaleMin</a>, the current size is scaled to a rectangle
242as large as possible inside (<em>w</em>, <em>h</em>), preserving the aspect ratio.
243<li> If <em>mode</em> is <a href="#ScaleMode-enum">ScaleMax</a>, the current size is scaled to a rectangle
244as small as possible outside (<em>w</em>, <em>h</em>), preserving the aspect ratio.
245</ul>
246<p> Example:
247<pre>
248 QSize t1( 10, 12 );
249 t1.<a href="#scale">scale</a>( 60, 60, QSize::<a href="#ScaleMode-enum">ScaleFree</a> );
250 // t1 is (60, 60)
251
252 QSize t2( 10, 12 );
253 t2.<a href="#scale">scale</a>( 60, 60, QSize::<a href="#ScaleMode-enum">ScaleMin</a> );
254 // t2 is (50, 60)
255
256 QSize t3( 10, 12 );
257 t3.<a href="#scale">scale</a>( 60, 60, QSize::<a href="#ScaleMode-enum">ScaleMax</a> );
258 // t3 is (60, 72)
259 </pre>
260
261
262<h3 class=fn>void <a name="scale-2"></a>QSize::scale ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s, <a href="qsize.html#ScaleMode-enum">ScaleMode</a>&nbsp;mode )
263</h3>
264This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
265<p> Equivalent to <a href="#scale">scale</a>(<em>s</em>.<a href="#width">width</a>(), <em>s</em>.<a href="#height">height</a>(), <em>mode</em>).
266
267<h3 class=fn>void <a name="setHeight"></a>QSize::setHeight ( int&nbsp;h )
268</h3>
269
270Sets the height to <em>h</em>.
271<p>See also <a href="#height">height</a>() and <a href="#setWidth">setWidth</a>().
272
273<h3 class=fn>void <a name="setWidth"></a>QSize::setWidth ( int&nbsp;w )
274</h3>
275
276Sets the width to <em>w</em>.
277<p>See also <a href="#width">width</a>() and <a href="#setHeight">setHeight</a>().
278
279<h3 class=fn>void <a name="transpose"></a>QSize::transpose ()
280</h3>
281Swaps the values of width and height.
282
283<h3 class=fn>int <a name="width"></a>QSize::width () const
284</h3>
285
286Returns the width.
287<p>See also <a href="#height">height</a>().
288
289<p>Examples: <a href="movies-example.html#x521">movies/main.cpp</a>, <a href="qfd-example.html#x2008">qfd/fontdisplayer.cpp</a>, and <a href="qfd-example.html#x2017">qfd/qfd.cpp</a>.
290<hr><h2>Related Functions</h2>
291<h3 class=fn>bool <a name="operator!-eq"></a>operator!= ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s1, const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s2 )
292</h3>
293
294
295Returns TRUE if <em>s1</em> and <em>s2</em> are different; otherwise returns FALSE.
296
297<h3 class=fn>const&nbsp;<a href="qsize.html">QSize</a> <a name="operator*"></a>operator* ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s, int&nbsp;c )
298</h3>
299
300
301Multiplies <em>s</em> by <em>c</em> and returns the result.
302
303<h3 class=fn>const&nbsp;<a href="qsize.html">QSize</a> <a name="operator*-2"></a>operator* ( int&nbsp;c, const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s )
304</h3>
305This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
306<p>
307Multiplies <em>s</em> by <em>c</em> and returns the result.
308
309<h3 class=fn>const&nbsp;<a href="qsize.html">QSize</a> <a name="operator*-3"></a>operator* ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s, double&nbsp;c )
310</h3>
311This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
312<p>
313Multiplies <em>s</em> by <em>c</em> and returns the result.
314
315<h3 class=fn>const&nbsp;<a href="qsize.html">QSize</a> <a name="operator*-4"></a>operator* ( double&nbsp;c, const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s )
316</h3>
317This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
318<p>
319Multiplies <em>s</em> by <em>c</em> and returns the result.
320
321<h3 class=fn>const&nbsp;<a href="qsize.html">QSize</a> <a name="operator+"></a>operator+ ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s1, const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s2 )
322</h3>
323
324
325Returns the sum of <em>s1</em> and <em>s2</em>; each component is added separately.
326
327<h3 class=fn>const&nbsp;<a href="qsize.html">QSize</a> <a name="operator-"></a>operator- ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s1, const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s2 )
328</h3>
329
330
331Returns <em>s2</em> subtracted from <em>s1</em>; each component is
332subtracted separately.
333
334<h3 class=fn>const&nbsp;<a href="qsize.html">QSize</a> <a name="operator/"></a>operator/ ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s, int&nbsp;c )
335</h3>
336
337
338Divides <em>s</em> by <em>c</em> and returns the result.
339
340<h3 class=fn>const&nbsp;<a href="qsize.html">QSize</a> <a name="operator/-2"></a>operator/ ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s, double&nbsp;c )
341</h3>
342
343
344This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
345<p> Divides <em>s</em> by <em>c</em> and returns the result.
346<p> Note that the result is truncated.
347
348<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-lt-lt"></a>operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;sz )
349</h3>
350
351Writes the size <em>sz</em> to the stream <em>s</em> and returns a reference to
352the stream.
353<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
354
355<h3 class=fn>bool <a name="operator-eq-eq"></a>operator== ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s1, const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;s2 )
356</h3>
357
358
359Returns TRUE if <em>s1</em> and <em>s2</em> are equal; otherwise returns FALSE.
360
361<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-gt-gt"></a>operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, <a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;sz )
362</h3>
363
364Reads the size from the stream <em>s</em> into size <em>sz</em> and returns a
365reference to the stream.
366<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
367
368<!-- eof -->
369<hr><p>
370This file is part of the <a href="index.html">Qt toolkit</a>.
371Copyright &copy; 1995-2007
372<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
373<table width=100% cellspacing=0 border=0><tr>
374<td>Copyright &copy; 2007
375<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
376<td align=right><div align=right>Qt 3.3.8</div>
377</table></div></address></body>
378</html>
Note: See TracBrowser for help on using the repository browser.