~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qsize.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
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/corelib/tools/qsize.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QSize 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>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
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">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <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">QSize Class Reference</h1>
 
21
<p>The QSize class defines the size of a two-dimensional object. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QSize&gt;</pre><p>Part of the <a href="qtcore.html">QtCore</a> module.</p>
 
23
<ul>
 
24
<li><a href="qsize-members.html">List of all members, including inherited members</a></li>
 
25
</ul>
 
26
<a name="public-functions"></a>
 
27
<h3>Public Functions</h3>
 
28
<ul>
 
29
<li><div class="fn"/><b><a href="qsize.html#QSize">QSize</a></b> ()</li>
 
30
<li><div class="fn"/><b><a href="qsize.html#QSize-2">QSize</a></b> ( int <i>w</i>, int <i>h</i> )</li>
 
31
<li><div class="fn"/>QSize <b><a href="qsize.html#boundedTo">boundedTo</a></b> ( const QSize &amp; <i>otherSize</i> ) const</li>
 
32
<li><div class="fn"/>QSize <b><a href="qsize.html#expandedTo">expandedTo</a></b> ( const QSize &amp; <i>otherSize</i> ) const</li>
 
33
<li><div class="fn"/>int <b><a href="qsize.html#height">height</a></b> () const</li>
 
34
<li><div class="fn"/>bool <b><a href="qsize.html#isEmpty">isEmpty</a></b> () const</li>
 
35
<li><div class="fn"/>bool <b><a href="qsize.html#isNull">isNull</a></b> () const</li>
 
36
<li><div class="fn"/>bool <b><a href="qsize.html#isValid">isValid</a></b> () const</li>
 
37
<li><div class="fn"/>int &amp; <b><a href="qsize.html#rheight">rheight</a></b> ()</li>
 
38
<li><div class="fn"/>int &amp; <b><a href="qsize.html#rwidth">rwidth</a></b> ()</li>
 
39
<li><div class="fn"/>void <b><a href="qsize.html#scale">scale</a></b> ( int <i>w</i>, int <i>h</i>, Qt::AspectRatioMode <i>mode</i> )</li>
 
40
<li><div class="fn"/>void <b><a href="qsize.html#scale-2">scale</a></b> ( const QSize &amp; <i>s</i>, Qt::AspectRatioMode <i>mode</i> )</li>
 
41
<li><div class="fn"/>void <b><a href="qsize.html#setHeight">setHeight</a></b> ( int <i>h</i> )</li>
 
42
<li><div class="fn"/>void <b><a href="qsize.html#setWidth">setWidth</a></b> ( int <i>w</i> )</li>
 
43
<li><div class="fn"/>void <b><a href="qsize.html#transpose">transpose</a></b> ()</li>
 
44
<li><div class="fn"/>int <b><a href="qsize.html#width">width</a></b> () const</li>
 
45
<li><div class="fn"/>QSize &amp; <b><a href="qsize.html#operator-2a-eq">operator*=</a></b> ( qreal <i>coeff</i> )</li>
 
46
<li><div class="fn"/>QSize &amp; <b><a href="qsize.html#operator-2b-eq">operator+=</a></b> ( const QSize &amp; <i>s</i> )</li>
 
47
<li><div class="fn"/>QSize &amp; <b><a href="qsize.html#operator--eq">operator-=</a></b> ( const QSize &amp; <i>s</i> )</li>
 
48
<li><div class="fn"/>QSize &amp; <b><a href="qsize.html#operator-2f-eq">operator/=</a></b> ( qreal <i>coeff</i> )</li>
 
49
</ul>
 
50
<a name="related-non-members"></a>
 
51
<h3>Related Non-Members</h3>
 
52
<ul>
 
53
<li><div class="fn"/>bool <b><a href="qsize.html#operator-not-eq-18">operator!=</a></b> ( const QSize &amp; <i>s1</i>, const QSize &amp; <i>s2</i> )</li>
 
54
<li><div class="fn"/>const QSize <b><a href="qsize.html#operator-2a">operator*</a></b> ( const QSize &amp; <i>size</i>, qreal <i>coeff</i> )</li>
 
55
<li><div class="fn"/>const QSize <b><a href="qsize.html#operator-2a-15">operator*</a></b> ( qreal <i>coeff</i>, const QSize &amp; <i>size</i> )</li>
 
56
<li><div class="fn"/>const QSize <b><a href="qsize.html#operator-2b-5">operator+</a></b> ( const QSize &amp; <i>s1</i>, const QSize &amp; <i>s2</i> )</li>
 
57
<li><div class="fn"/>const QSize <b><a href="qsize.html#operator--4">operator-</a></b> ( const QSize &amp; <i>s1</i>, const QSize &amp; <i>s2</i> )</li>
 
58
<li><div class="fn"/>const QSize <b><a href="qsize.html#operator-2f-4">operator/</a></b> ( const QSize &amp; <i>size</i>, qreal <i>divisor</i> )</li>
 
59
<li><div class="fn"/>QDataStream &amp; <b><a href="qsize.html#operator-lt-lt-48">operator&lt;&lt;</a></b> ( QDataStream &amp; <i>s</i>, const QSize &amp; <i>sz</i> )</li>
 
60
<li><div class="fn"/>bool <b><a href="qsize.html#operator-eq-eq-25">operator==</a></b> ( const QSize &amp; <i>s1</i>, const QSize &amp; <i>s2</i> )</li>
 
61
<li><div class="fn"/>QDataStream &amp; <b><a href="qsize.html#operator-gt-gt-31">operator&gt;&gt;</a></b> ( QDataStream &amp; <i>s</i>, QSize &amp; <i>sz</i> )</li>
 
62
</ul>
 
63
<a name="details"></a>
 
64
<hr />
 
65
<h2>Detailed Description</h2>
 
66
<p>The QSize class defines the size of a two-dimensional object.</p>
 
67
<p>A size is specified by a width and a height.</p>
 
68
<p>The size can be set in the constructor and changed with <a href="qsize.html#setWidth">setWidth</a>(), <a href="qsize.html#setHeight">setHeight</a>(), or <a href="qsize.html#scale">scale</a>(), or using arithmetic operators. You can swap the width and height with <a href="qsize.html#transpose">transpose</a>(). You can get a size which holds the maximum height and width of two sizes using <a href="qsize.html#expandedTo">expandedTo</a>(), and the minimum height and width of two sizes using <a href="qsize.html#boundedTo">boundedTo</a>().</p>
 
69
<p>See also <a href="qpoint.html">QPoint</a>, <a href="qrect.html">QRect</a>, and <a href="qsizef.html">QSizeF</a>.</p>
 
70
<hr />
 
71
<h2>Member Function Documentation</h2>
 
72
<h3 class="fn"><a name="QSize"></a>QSize::QSize ()</h3>
 
73
<p>Constructs a size with an invalid width and height.</p>
 
74
<p>See also <a href="qsize.html#isValid">isValid</a>(), <a href="qsize.html#setWidth">setWidth</a>(), and <a href="qsize.html#setHeight">setHeight</a>().</p>
 
75
<h3 class="fn"><a name="QSize-2"></a>QSize::QSize ( int <i>w</i>, int <i>h</i> )</h3>
 
76
<p>Constructs a size with width <i>w</i> and height <i>h</i>.</p>
 
77
<h3 class="fn"><a name="boundedTo"></a>QSize QSize::boundedTo ( const QSize &amp; <i>otherSize</i> ) const</h3>
 
78
<p>Returns a size with the minimum width and height of this size and <i>otherSize</i>.</p>
 
79
<p>See also <a href="qsize.html#expandedTo">expandedTo</a>(), <a href="qsize.html#scale">scale</a>(), <a href="qsize.html#setWidth">setWidth</a>(), and <a href="qsize.html#setHeight">setHeight</a>().</p>
 
80
<h3 class="fn"><a name="expandedTo"></a>QSize QSize::expandedTo ( const QSize &amp; <i>otherSize</i> ) const</h3>
 
81
<p>Returns a size with the maximum width and height of this size and <i>otherSize</i>.</p>
 
82
<p>See also <a href="qsize.html#boundedTo">boundedTo</a>(), <a href="qsize.html#scale">scale</a>(), <a href="qsize.html#setWidth">setWidth</a>(), and <a href="qsize.html#setHeight">setHeight</a>().</p>
 
83
<h3 class="fn"><a name="height"></a>int QSize::height () const</h3>
 
84
<p>Returns the height.</p>
 
85
<p>See also <a href="qsize.html#width">width</a>() and <a href="qsize.html#setHeight">setHeight</a>().</p>
 
86
<h3 class="fn"><a name="isEmpty"></a>bool QSize::isEmpty () const</h3>
 
87
<p>Returns true if the width is less than or equal to 0, or the height is less than or equal to 0; otherwise returns false.</p>
 
88
<p>See also <a href="qsize.html#isNull">isNull</a>(), <a href="qsize.html#isValid">isValid</a>(), <a href="qsize.html#width">width</a>(), and <a href="qsize.html#height">height</a>().</p>
 
89
<h3 class="fn"><a name="isNull"></a>bool QSize::isNull () const</h3>
 
90
<p>Returns true if the width is 0 and the height is 0; otherwise returns false.</p>
 
91
<p>See also <a href="qsize.html#isValid">isValid</a>(), <a href="qsize.html#isEmpty">isEmpty</a>(), <a href="qsize.html#width">width</a>(), and <a href="qsize.html#height">height</a>().</p>
 
92
<h3 class="fn"><a name="isValid"></a>bool QSize::isValid () const</h3>
 
93
<p>Returns true if the width is equal to or greater than 0 and the height is equal to or greater than 0; otherwise returns false.</p>
 
94
<p>See also <a href="qsize.html#isNull">isNull</a>(), <a href="qsize.html#isEmpty">isEmpty</a>(), <a href="qsize.html#width">width</a>(), and <a href="qsize.html#height">height</a>().</p>
 
95
<h3 class="fn"><a name="rheight"></a>int &amp; QSize::rheight ()</h3>
 
96
<p>Returns a reference to the height.</p>
 
97
<p>Using a reference makes it possible to directly manipulate the height.</p>
 
98
<p>Example:</p>
 
99
<pre>&nbsp;   QSize s(100, 10);
 
100
    s.rheight() += 5;                // s becomes (100,15)</pre>
 
101
<p>See also <a href="qsize.html#rwidth">rwidth</a>() and <a href="qsize.html#setHeight">setHeight</a>().</p>
 
102
<h3 class="fn"><a name="rwidth"></a>int &amp; QSize::rwidth ()</h3>
 
103
<p>Returns a reference to the width.</p>
 
104
<p>Using a reference makes it possible to directly manipulate the width.</p>
 
105
<p>Example:</p>
 
106
<pre>&nbsp;   QSize s(100, 10);
 
107
    s.rwidth() += 20;                // s becomes (120,10)</pre>
 
108
<p>See also <a href="qsize.html#rheight">rheight</a>() and <a href="qsize.html#setWidth">setWidth</a>().</p>
 
109
<h3 class="fn"><a name="scale"></a>void QSize::scale ( int <i>w</i>, int <i>h</i>, <a href="qt.html#AspectRatioMode-enum">Qt::AspectRatioMode</a> <i>mode</i> )</h3>
 
110
<p>Scales the size to a rectangle of width <i>w</i> and height <i>h</i> according to the <a href="qt.html#AspectRatioMode-enum">Qt::AspectRatioMode</a> <i>mode</i>.</p>
 
111
<ul>
 
112
<li>If <i>mode</i> is <tt>Qt::IgnoreAspectRatio</tt>, the size is set to (<i>w</i>, <i>h</i>).</li>
 
113
<li>If <i>mode</i> is <tt>Qt::KeepAspectRatio</tt>, the current size is scaled to a rectangle as large as possible inside (<i>w</i>, <i>h</i>), preserving the aspect ratio.</li>
 
114
<li>If <i>mode</i> is <tt>Qt::KeepAspectRatioByExpanding</tt>, the current size is scaled to a rectangle as small as possible outside (<i>w</i>, <i>h</i>), preserving the aspect ratio.</li>
 
115
</ul>
 
116
<p>Example:</p>
 
117
<pre>&nbsp;   QSize t1(10, 12);
 
118
    t1.scale(60, 60, QSize::IgnoreAspectRatio);
 
119
    // t1 is (60, 60)
 
120
 
 
121
    QSize t2(10, 12);
 
122
    t2.scale(60, 60, QSize::KeepAspectRatio);
 
123
    // t2 is (50, 60)
 
124
 
 
125
    QSize t3(10, 12);
 
126
    t3.scale(60, 60, QSize::KeepAspectRatioByExpanding);
 
127
    // t3 is (60, 72)</pre>
 
128
<p>See also <a href="qsize.html#boundedTo">boundedTo</a>(), <a href="qsize.html#expandedTo">expandedTo</a>(), <a href="qsize.html#setWidth">setWidth</a>(), and <a href="qsize.html#setHeight">setHeight</a>().</p>
 
129
<h3 class="fn"><a name="scale-2"></a>void QSize::scale ( const QSize &amp; <i>s</i>, <a href="qt.html#AspectRatioMode-enum">Qt::AspectRatioMode</a> <i>mode</i> )</h3>
 
130
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
131
<p>Equivalent to scale(<i>s</i>.<a href="qsize.html#width">width</a>(), <i>s</i>.<a href="qsize.html#height">height</a>(), <i>mode</i>).</p>
 
132
<h3 class="fn"><a name="setHeight"></a>void QSize::setHeight ( int <i>h</i> )</h3>
 
133
<p>Sets the height to <i>h</i>.</p>
 
134
<p>See also <a href="qsize.html#height">height</a>(), <a href="qsize.html#rheight">rheight</a>(), <a href="qsize.html#setWidth">setWidth</a>(), <a href="qsize.html#expandedTo">expandedTo</a>(), <a href="qsize.html#boundedTo">boundedTo</a>(), <a href="qsize.html#scale">scale</a>(), and <a href="qsize.html#transpose">transpose</a>().</p>
 
135
<h3 class="fn"><a name="setWidth"></a>void QSize::setWidth ( int <i>w</i> )</h3>
 
136
<p>Sets the width to <i>w</i>.</p>
 
137
<p>See also <a href="qsize.html#width">width</a>(), <a href="qsize.html#rwidth">rwidth</a>(), <a href="qsize.html#setHeight">setHeight</a>(), <a href="qsize.html#expandedTo">expandedTo</a>(), <a href="qsize.html#boundedTo">boundedTo</a>(), <a href="qsize.html#scale">scale</a>(), and <a href="qsize.html#transpose">transpose</a>().</p>
 
138
<h3 class="fn"><a name="transpose"></a>void QSize::transpose ()</h3>
 
139
<p>Swaps the width and height values.</p>
 
140
<p>See also <a href="qsize.html#expandedTo">expandedTo</a>(), <a href="qsize.html#boundedTo">boundedTo</a>(), <a href="qsize.html#setWidth">setWidth</a>(), and <a href="qsize.html#setHeight">setHeight</a>().</p>
 
141
<h3 class="fn"><a name="width"></a>int QSize::width () const</h3>
 
142
<p>Returns the width.</p>
 
143
<p>See also <a href="qsize.html#height">height</a>() and <a href="qsize.html#setWidth">setWidth</a>().</p>
 
144
<h3 class="fn"><a name="operator-2a-eq"></a>QSize &amp; QSize::operator*= ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>coeff</i> )</h3>
 
145
<p>Multiplies both the width and height by <i>coeff</i> and returns a reference to the size.</p>
 
146
<p>Note that the result is rounded to the nearest integer.</p>
 
147
<h3 class="fn"><a name="operator-2b-eq"></a>QSize &amp; QSize::operator+= ( const QSize &amp; <i>s</i> )</h3>
 
148
<p>Adds <i>s</i> to the size and returns a reference to this size.</p>
 
149
<p>Example:</p>
 
150
<pre>&nbsp;   QSize s( 3, 7);
 
151
    QSize r(-1, 4);
 
152
    s += r;                        // s becomes (2,11)</pre>
 
153
<h3 class="fn"><a name="operator--eq"></a>QSize &amp; QSize::operator-= ( const QSize &amp; <i>s</i> )</h3>
 
154
<p>Subtracts <i>s</i> from the size and returns a reference to this size.</p>
 
155
<p>Example:</p>
 
156
<pre>&nbsp;   QSize s( 3, 7);
 
157
    QSize r(-1, 4);
 
158
    s -= r;                        // s becomes (4,3)</pre>
 
159
<h3 class="fn"><a name="operator-2f-eq"></a>QSize &amp; QSize::operator/= ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>coeff</i> )</h3>
 
160
<p>Divides both the width and height by <i>coeff</i> and returns a reference to the size.</p>
 
161
<p>Note that the result is rounded to the nearest integer.</p>
 
162
<p>See also <a href="qsize.html#scale">QSize::scale</a>().</p>
 
163
<hr />
 
164
<h2>Related Non-Members</h2>
 
165
<h3 class="fn"><a name="operator-not-eq-18"></a>bool operator!= ( const QSize &amp; <i>s1</i>, const QSize &amp; <i>s2</i> )</h3>
 
166
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
167
<p>Returns true if <i>s1</i> and <i>s2</i> are different; otherwise returns false.</p>
 
168
<h3 class="fn"><a name="operator-2a"></a>const QSize operator* ( const QSize &amp; <i>size</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>coeff</i> )</h3>
 
169
<p>Multiplies <i>size</i> by <i>coeff</i> and returns the result rounded to the nearest integer.</p>
 
170
<p>See also <a href="qsize.html#scale">QSize::scale</a>().</p>
 
171
<h3 class="fn"><a name="operator-2a-15"></a>const QSize operator* ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>coeff</i>, const QSize &amp; <i>size</i> )</h3>
 
172
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
173
<p>Multiplies <i>size</i> by <i>coeff</i> and returns the result rounded to the nearest integer.</p>
 
174
<p>See also <a href="qsize.html#scale">QSize::scale</a>().</p>
 
175
<h3 class="fn"><a name="operator-2b-5"></a>const QSize operator+ ( const QSize &amp; <i>s1</i>, const QSize &amp; <i>s2</i> )</h3>
 
176
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
177
<p>Returns the sum of <i>s1</i> and <i>s2</i>; each component is added separately.</p>
 
178
<h3 class="fn"><a name="operator--4"></a>const QSize operator- ( const QSize &amp; <i>s1</i>, const QSize &amp; <i>s2</i> )</h3>
 
179
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
180
<p>Returns <i>s2</i> subtracted from <i>s1</i>; each component is subtracted separately.</p>
 
181
<h3 class="fn"><a name="operator-2f-4"></a>const QSize operator/ ( const QSize &amp; <i>size</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>divisor</i> )</h3>
 
182
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
183
<p>Divides <i>size</i> by <i>divisor</i> and returns the result.</p>
 
184
<p>Note that the result is rounded to the nearest integer.</p>
 
185
<p>See also <a href="qsize.html#scale">QSize::scale</a>().</p>
 
186
<h3 class="fn"><a name="operator-lt-lt-48"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>s</i>, const QSize &amp; <i>sz</i> )</h3>
 
187
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
188
<p>Writes the size <i>sz</i> to the stream <i>s</i> and returns a reference to the stream.</p>
 
189
<p>See also <a href="datastreamformat.html">Format of the QDataStream
 
190
    operators</a>.</p>
 
191
<h3 class="fn"><a name="operator-eq-eq-25"></a>bool operator== ( const QSize &amp; <i>s1</i>, const QSize &amp; <i>s2</i> )</h3>
 
192
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
193
<p>Returns true if <i>s1</i> and <i>s2</i> are equal; otherwise returns false.</p>
 
194
<h3 class="fn"><a name="operator-gt-gt-31"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>s</i>, QSize &amp; <i>sz</i> )</h3>
 
195
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
196
<p>Reads the size from the stream <i>s</i> into size <i>sz</i> and returns a reference to the stream.</p>
 
197
<p>See also <a href="datastreamformat.html">Format of the QDataStream
 
198
    operators</a>.</p>
 
199
<p /><address><hr /><div align="center">
 
200
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
201
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
202
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
203
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
204
</tr></table></div></address></body>
 
205
</html>