File: qpoint.html

package info (click to toggle)
qt-embedded 2.3.2-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 68,608 kB
  • ctags: 45,998
  • sloc: cpp: 276,654; ansic: 71,987; makefile: 29,074; sh: 12,305; yacc: 2,465; python: 1,863; perl: 481; lex: 480; xml: 68; lisp: 15
file content (253 lines) | stat: -rw-r--r-- 13,985 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QPoint Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">

<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>

<h1 align=center>QPoint Class Reference</h1><br clear="all">
<p>
The QPoint class defines a point in the plane.
<a href="#details">More...</a>
<p>
<code>#include &lt;<a href="qpoint-h.html">qpoint.h</a>&gt;</code>
<p><a href="qpoint-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#38e511"><b>QPoint</b></a>()</div>
<li><div class="fn"><a href="#b56557"><b>QPoint</b></a>(intxpos, intypos)</div>
<li><div class="fn">bool<a href="#b75100"><b>isNull</b></a>()const</div>
<li><div class="fn">int<a href="#7e96b2"><b>x</b></a>()const</div>
<li><div class="fn">int<a href="#e48824"><b>y</b></a>()const</div>
<li><div class="fn">void<a href="#75b57f"><b>setX</b></a>(intx)</div>
<li><div class="fn">void<a href="#c780b4"><b>setY</b></a>(inty)</div>
<li><div class="fn">int<a href="#2fcb0e"><b>manhattanLength</b></a>()const</div>
<li><div class="fn">QCOORD&amp;<a href="#bc236e"><b>rx</b></a>()</div>
<li><div class="fn">QCOORD&amp;<a href="#17eba0"><b>ry</b></a>()</div>
<li><div class="fn">QPoint&amp;<a href="#fbeb96"><b>operator+=</b></a>(constQPoint&amp;p)</div>
<li><div class="fn">QPoint&amp;<a href="#c4f49f"><b>operator-=</b></a>(constQPoint&amp;p)</div>
<li><div class="fn">QPoint&amp;<a href="#156b66"><b>operator*=</b></a>(intc)</div>
<li><div class="fn">QPoint&amp;<a href="#d66de7"><b>operator*=</b></a>(doublec)</div>
<li><div class="fn">QPoint&amp;<a href="#6c68e1"><b>operator/=</b></a>(intc)</div>
<li><div class="fn">QPoint&amp;<a href="#6ea8ca"><b>operator/=</b></a>(doublec)</div>
</ul>
<h2>Related Functions</h2>
(Note that these are not member functions.)
<ul>
<li>QPoint <a href="qpoint.html#1b3f41"><b>operator/</b></a> (const QPoint &amp; p, double c)
<li>QPoint <a href="qpoint.html#25d7f1"><b>operator*</b></a> (double c, const QPoint &amp; p)
<li>QPoint <a href="qpoint.html#2a667f"><b>operator/</b></a> (const QPoint &amp; p, int c)
<li>QDataStream &amp; <a href="qpoint.html#32d460"><b>operator&lt;&lt;</b></a> (QDataStream &amp; s, const QPoint &amp; p)
<li>QPoint <a href="qpoint.html#3f935a"><b>operator*</b></a> (int c, const QPoint &amp; p)
<li>QDataStream &amp; <a href="qpoint.html#44a4cb"><b>operator&gt;&gt;</b></a> (QDataStream &amp; s, QPoint &amp; p)
<li>QPoint <a href="qpoint.html#550c91"><b>operator*</b></a> (const QPoint &amp; p, double c)
<li>QPoint <a href="qpoint.html#7b4ffd"><b>operator*</b></a> (const QPoint &amp; p, int c)
<li>QPoint <a href="qpoint.html#8f8499"><b>operator+</b></a> (const QPoint &amp; p1, const QPoint &amp; p2)
<li>bool <a href="qpoint.html#bf658e"><b>operator!=</b></a> (const QPoint &amp; p1, const QPoint &amp; p2)
<li>QPoint <a href="qpoint.html#bf81ba"><b>operator-</b></a> (const QPoint &amp; p)
<li>bool <a href="qpoint.html#c19b5c"><b>operator==</b></a> (const QPoint &amp; p1, const QPoint &amp; p2)
<li>QPoint <a href="qpoint.html#cfa22c"><b>operator-</b></a> (const QPoint &amp; p1, const QPoint &amp; p2)
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QPoint class defines a point in the plane.
<p>
A point is specified by an x coordinate and a y coordinate.
<p>The coordinate type is <code>QCOORD</code> (a 32-bit integer).
The minimum value of <code>QCOORD</code> is <code>QCOORD_MIN</code> (-2147483648) and the maximum
value is  <code>QCOORD_MAX</code> (2147483647).
<p>The coordinates are accessed by the functions <a href="#7e96b2">x</a>() and <a href="#e48824">y</a>(), they can
be set by <a href="#75b57f">setX</a>() and <a href="#c780b4">setY</a>(), or by the reference functions <a href="#bc236e">rx</a>() and <a href="#17eba0">ry</a>().
<p>Given a point <em>p,</em> the following statements are all equivalent:
<pre>     p.setX( p.x() + 1 );
     p += QPoint( 1, 0 );
     p.rx()++;
</pre>
<p>A QPoint can also be used as a vector.  Addition and subtraction of
QPoint are defined as for vectors (each component is added
separately). You can divide or multiply a QPoint by an <code>int</code> or a
<code>double.</code> The function <a href="#2fcb0e">manhattanLength</a>() gives an inexpensive
approximation to the length of the QPoint interpreted as a vector.
<p>Example:
<pre>     //QPoint oldPos is defined somewhere else 
     MyWidget::mouseMoveEvent( <a href="qmouseevent.html">QMouseEvent</a> *e )
     {
        <a href="qpoint.html">QPoint</a> vector = e-&gt;<a href="qmouseevent.html#ac6f25">pos</a>() - oldPos;
        if ( vector.<a href="#2fcb0e">manhattanLength</a>() &gt; 3 )
           ... //mouse has moved more than 3 pixels since oldPos
     }
</pre>
<p>QPoints can be compared for equality or inequality, and they can be
written to and read from a QStream.
<p>See also  <a href="qsize.html">QSize</a> and <a href="qrect.html">QRect</a>.
<p>Examples:
 <a href="drawlines-connect-cpp.html#QPoint">drawlines/connect.cpp</a>
 <a href="xform-xform-cpp.html#QPoint">xform/xform.cpp</a>
 <a href="qmag-qmag-cpp.html#QPoint">qmag/qmag.cpp</a>
 <a href="forever-forever-cpp.html#QPoint">forever/forever.cpp</a>

<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="38e511"></a>QPoint::QPoint()</h3>
<p>Constructs a point with coordinates (0,0) (<a href="#b75100">isNull</a>() returns TRUE).
<h3 class="fn"><a name="b56557"></a>QPoint::QPoint(intxpos, intypos)</h3>
<p>Constructs a point with the x value  <em>xpos</em> and y value <em>ypos.</em>
<h3 class="fn">bool<a name="b75100"></a>QPoint::isNull()const</h3>
<p>Returns TRUE if both the x value and the y value are 0.
<h3 class="fn">int<a name="2fcb0e"></a>QPoint::manhattanLength()const</h3>
<p>Returns the sum of the absolute values of <a href="#7e96b2">x</a>() and <a href="#e48824">y</a>(), traditionally
known as the "Manhattan length" of the vector from the origin to the
point. The tradition arises since such distances apply
to travelers who can only travel on a rectangular grid, like the streets
of Manhattan.
<p>This is a useful approximation to the true length,
sqrt(pow(x(),2)+pow(y(),2)).
<h3 class="fn">QPoint&amp;<a name="d66de7"></a>QPoint::operator*=(doublec)</h3>
<p>Multiplies both x and y with <em>c,</em> and return a reference to this point.
<p>Example:
<pre>    <a href="qpoint.html">QPoint</a> p( -1, 4 );
    p *= 2.5;                   // p becomes (-3,10)
</pre>
<p>Note that the result is truncated.
<h3 class="fn">QPoint&amp;<a name="156b66"></a>QPoint::operator*=(intc)</h3>
<p>Multiplies both x and y with <em>c,</em> and return a reference to this point.
<p>Example:
<pre>    <a href="qpoint.html">QPoint</a> p( -1, 4 );
    p *= 2;                     // p becomes (-2,8)
</pre>
<h3 class="fn">QPoint&amp;<a name="fbeb96"></a>QPoint::operator+=(constQPoint&amp;p)</h3>
<p>Adds <em>p</em> to the point and returns a reference to this point.
<p>Example:
<pre>    <a href="qpoint.html">QPoint</a> p(  3, 7 );
    <a href="qpoint.html">QPoint</a> q( -1, 4 );
    p += q;                     // p becomes (2,11)
</pre>
<h3 class="fn">QPoint&amp;<a name="c4f49f"></a>QPoint::operator-=(constQPoint&amp;p)</h3>
<p>Subtracts <em>p</em> from the point and returns a reference to this point.
<p>Example:
<pre>    <a href="qpoint.html">QPoint</a> p(  3, 7 );
    <a href="qpoint.html">QPoint</a> q( -1, 4 );
    p -= q;                     // p becomes (4,3)
</pre>
<h3 class="fn">QPoint&amp;<a name="6ea8ca"></a>QPoint::operator/=(doublec)</h3>
<p>Divides both x and y by <em>c,</em> and return a reference to this point.
<p>Example:
<pre>    <a href="qpoint.html">QPoint</a> p( -3, 10 );
    p /= 2.5;                   // p becomes (-1,4)
</pre>
<p>Note that the result is truncated.
<h3 class="fn">QPoint&amp;<a name="6c68e1"></a>QPoint::operator/=(intc)</h3>
<p>Divides both x and y by <em>c,</em> and return a reference to this point.
<p>Example:
<pre>    <a href="qpoint.html">QPoint</a> p( -2, 8 );
    p /= 2;                     // p becomes (-1,4)
</pre>
<h3 class="fn">QCOORD&amp;<a name="bc236e"></a>QPoint::rx()</h3>
<p>Returns a reference to the x coordinate of the point.
<p>Using a reference makes it possible to directly manipulate x.
<p>Example:
<pre>    <a href="qpoint.html">QPoint</a> p( 1, 2 );
    p.<a href="#bc236e">rx</a>()--;                   // p becomes (0,2)
</pre>
<p>See also  <a href="#17eba0">ry</a>().
<h3 class="fn">QCOORD&amp;<a name="17eba0"></a>QPoint::ry()</h3>
<p>Returns a reference to the y coordinate of the point.
<p>Using a reference makes it possible to directly manipulate y.
<p>Example:
<pre>    <a href="qpoint.html">QPoint</a> p( 1, 2 );
    p.<a href="#17eba0">ry</a>()++;                   // p becomes (1,3)
</pre>
<p>See also  <a href="#bc236e">rx</a>().
<h3 class="fn">void<a name="75b57f"></a>QPoint::setX(intx)</h3>
<p>Sets the x coordinate of the point to <em>x.</em>
<p>See also  <a href="#7e96b2">x</a>() and <a href="#c780b4">setY</a>().
<h3 class="fn">void<a name="c780b4"></a>QPoint::setY(inty)</h3>
<p>Sets the y coordinate of the point to <em>y.</em>
<p>See also  <a href="#e48824">y</a>() and <a href="#75b57f">setX</a>().
<h3 class="fn">int<a name="7e96b2"></a>QPoint::x()const</h3>
<p>Returns the x coordinate of the point.
<p>See also  <a href="#75b57f">setX</a>() and <a href="#e48824">y</a>().
<h3 class="fn">int<a name="e48824"></a>QPoint::y()const</h3>
<p>Returns the y coordinate of the point.
<p>See also  <a href="#c780b4">setY</a>() and <a href="#7e96b2">x</a>().
<hr><h2>Related Functions</h2>
<h3>QPoint <a name="1b3f41"></a>operator/ (const QPoint &amp; p, double c)</h3>
<p>Returns the QPoint formed by dividing both components of <em>p</em>
by <em>c.</em>
<p>Note that the result is truncated.

<h3>QPoint <a name="25d7f1"></a>operator* (double c, const QPoint &amp; p)</h3>
<p>Returns the QPoint formed by multiplying both components of <em>p</em>
by <em>c.</em>
<p>Note that the result is truncated.

<h3>QPoint <a name="2a667f"></a>operator/ (const QPoint &amp; p, int c)</h3>
<p>Returns the QPoint formed by dividing both components of <em>p</em>
by <em>c.</em>

<h3><a href="qdatastream.html">QDataStream</a> &amp; <a name="32d460"></a>operator&lt;&lt; (<a href="qdatastream.html">QDataStream</a> &amp; s, const QPoint &amp; p)</h3>
<p>Writes a QPoint to the stream and returns a reference to the stream.
<p>See also  <a href="datastreamformat.html">Format of the QDataStream operators</a>

<h3>QPoint <a name="3f935a"></a>operator* (int c, const QPoint &amp; p)</h3>
<p>Returns the QPoint formed by multiplying both components of <em>p</em>
by <em>c.</em>

<h3><a href="qdatastream.html">QDataStream</a> &amp; <a name="44a4cb"></a>operator&gt;&gt; (<a href="qdatastream.html">QDataStream</a> &amp; s, QPoint &amp; p)</h3>
<p>Reads a QPoint from the stream and returns a reference to the stream.
<p>See also  <a href="datastreamformat.html">Format of the QDataStream operators</a>

<h3>QPoint <a name="550c91"></a>operator* (const QPoint &amp; p, double c)</h3>
<p>Returns the QPoint formed by multiplying both components of <em>p</em>
by <em>c.</em>
<p>Note that the result is truncated.

<h3>QPoint <a name="7b4ffd"></a>operator* (const QPoint &amp; p, int c)</h3>
<p>Returns the QPoint formed by multiplying both components of <em>p</em>
by <em>c.</em>

<h3>QPoint <a name="8f8499"></a>operator+ (const QPoint &amp; p1, const QPoint &amp; p2)</h3>
<p>Returns the sum of <em>p1</em> and <em>p2;</em> each component is added separately.

<h3>bool <a name="bf658e"></a>operator!= (const QPoint &amp; p1, const QPoint &amp; p2)</h3>
<p>Returns TRUE if <em>p1</em> and <em>p2</em> are different, or FALSE if they are equal.

<h3>QPoint <a name="bf81ba"></a>operator- (const QPoint &amp; p)</h3>
<p>Returns the QPoint formed by changing the sign of both components of
<em>p,</em> equivalent to <code>QPoint(0,0) - p</code>

<h3>bool <a name="c19b5c"></a>operator== (const QPoint &amp; p1, const QPoint &amp; p2)</h3>
<p>Returns TRUE if <em>p1</em> and <em>p2</em> are equal, or FALSE if they are different.

<h3>QPoint <a name="cfa22c"></a>operator- (const QPoint &amp; p1, const QPoint &amp; p2)</h3>
<p>Returns <em>p2</em> subtracted from <em>p1;</em> each component is
subtracted separately.

<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright &copy; 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright  2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>