1QPoint(3qt)                                                        QPoint(3qt)
2
3
4

NAME

6       QPoint - Defines a point in the plane
7

SYNOPSIS

9       #include <qpoint.h>
10
11   Public Members
12       QPoint ()
13       QPoint ( int xpos, int ypos )
14       bool isNull () const
15       int x () const
16       int y () const
17       void setX ( int x )
18       void setY ( int y )
19       int manhattanLength () const
20       QCOORD & rx ()
21       QCOORD & ry ()
22       QPoint & operator+= ( const QPoint & p )
23       QPoint & operator-= ( const QPoint & p )
24       QPoint & operator*= ( int c )
25       QPoint & operator*= ( double c )
26       QPoint & operator/= ( int c )
27       QPoint & operator/= ( double c )
28
30       bool operator== ( const QPoint & p1, const QPoint & p2 )
31       bool operator!= ( const QPoint & p1, const QPoint & p2 )
32       const QPoint operator+ ( const QPoint & p1, const QPoint & p2 )
33       const QPoint operator- ( const QPoint & p1, const QPoint & p2 )
34       const QPoint operator* ( const QPoint & p, int c )
35       const QPoint operator* ( int c, const QPoint & p )
36       const QPoint operator* ( const QPoint & p, double c )
37       const QPoint operator* ( double c, const QPoint & p )
38       const QPoint operator- ( const QPoint & p )
39       const QPoint operator/ ( const QPoint & p, int c )
40       const QPoint operator/ ( const QPoint & p, double c )
41       QDataStream & operator<< ( QDataStream & s, const QPoint & p )
42       QDataStream & operator>> ( QDataStream & s, QPoint & p )
43

DESCRIPTION

45       The QPoint class defines a point in the plane.
46
47       A point is specified by an x coordinate and a y coordinate.
48
49       The coordinate type is QCOORD (a 32-bit integer). The minimum value of
50       QCOORD is QCOORD_MIN (-2147483648) and the maximum value is QCOORD_MAX
51       (2147483647).
52
53       The coordinates are accessed by the functions x() and y(); they can be
54       set by setX() and setY() or by the reference functions rx() and ry().
55
56       Given a point p, the following statements are all equivalent:
57
58               p.setX( p.x() + 1 );
59               p += QPoint( 1, 0 );
60               p.rx()++;
61
62       A QPoint can also be used as a vector. Addition and subtraction of
63       QPoints are defined as for vectors (each component is added
64       separately). You can divide or multiply a QPoint by an int or a double.
65       The function manhattanLength() gives an inexpensive approximation of
66       the length of the QPoint interpreted as a vector.
67
68       Example:
69
70               //QPoint oldPos is defined somewhere else
71               MyWidget::mouseMoveEvent( QMouseEvent *e )
72               {
73                   QPoint vector = e->pos() - oldPos;
74                   if ( vector.manhattanLength() > 3 )
75                   ... //mouse has moved more than 3 pixels since oldPos
76               }
77
78       QPoints can be compared for equality or inequality, and they can be
79       written to and read from a QStream.
80
81       See also QPointArray, QSize, QRect, Graphics Classes, and Image
82       Processing Classes.
83

MEMBER FUNCTION DOCUMENTATION

QPoint::QPoint ()

86       Constructs a point with coordinates (0, 0) (isNull() returns TRUE).
87

QPoint::QPoint ( int xpos, int ypos )

89       Constructs a point with x value xpos and y value ypos.
90

bool QPoint::isNull () const

92       Returns TRUE if both the x value and the y value are 0; otherwise
93       returns FALSE.
94

int QPoint::manhattanLength () const

96       Returns the sum of the absolute values of x() and y(), traditionally
97       known as the "Manhattan length" of the vector from the origin to the
98       point. The tradition arises because such distances apply to travelers
99       who can only travel on a rectangular grid, like the streets of
100       Manhattan.
101
102       This is a useful, and quick to calculate, approximation to the true
103       length: sqrt(pow(x(),2)+pow(y(),2)).
104

QPoint & QPoint::operator*= ( int c )

106       Multiplies this point's x and y by c, and returns a reference to this
107       point.
108
109       Example:
110
111               QPoint p( -1, 4 );
112               p *= 2;            // p becomes (-2,8)
113

QPoint & QPoint::operator*= ( double c )

115       This is an overloaded member function, provided for convenience. It
116       behaves essentially like the above function.
117
118       Multiplies this point's x and y by c, and returns a reference to this
119       point.
120
121       Example:
122
123               QPoint p( -1, 4 );
124               p *= 2.5;          // p becomes (-3,10)
125
126       Note that the result is truncated because points are held as integers.
127

QPoint & QPoint::operator+= ( const QPoint & p )

129       Adds point p to this point and returns a reference to this point.
130
131       Example:
132
133               QPoint p(  3, 7 );
134               QPoint q( -1, 4 );
135               p += q;            // p becomes (2,11)
136

QPoint & QPoint::operator-= ( const QPoint & p )

138       Subtracts point p from this point and returns a reference to this
139       point.
140
141       Example:
142
143               QPoint p(  3, 7 );
144               QPoint q( -1, 4 );
145               p -= q;            // p becomes (4,3)
146

QPoint & QPoint::operator/= ( int c )

148       Divides both x and y by c, and returns a reference to this point.
149
150       Example:
151
152               QPoint p( -2, 8 );
153               p /= 2;            // p becomes (-1,4)
154

QPoint & QPoint::operator/= ( double c )

156       This is an overloaded member function, provided for convenience. It
157       behaves essentially like the above function.
158
159       Divides both x and y by c, and returns a reference to this point.
160
161       Example:
162
163               QPoint p( -3, 10 );
164               p /= 2.5;           // p becomes (-1,4)
165
166       Note that the result is truncated because points are held as integers.
167

QCOORD & QPoint::rx ()

169       Returns a reference to the x coordinate of the point.
170
171       Using a reference makes it possible to directly manipulate x.
172
173       Example:
174
175               QPoint p( 1, 2 );
176               p.rx()--;         // p becomes (0, 2)
177
178       See also ry().
179

QCOORD & QPoint::ry ()

181       Returns a reference to the y coordinate of the point.
182
183       Using a reference makes it possible to directly manipulate y.
184
185       Example:
186
187               QPoint p( 1, 2 );
188               p.ry()++;         // p becomes (1, 3)
189
190       See also rx().
191

void QPoint::setX ( int x )

193       Sets the x coordinate of the point to x.
194
195       See also x() and setY().
196
197       Example: t14/cannon.cpp.
198

void QPoint::setY ( int y )

200       Sets the y coordinate of the point to y.
201
202       See also y() and setX().
203
204       Example: t14/cannon.cpp.
205

int QPoint::x () const

207       Returns the x coordinate of the point.
208
209       See also setX() and y().
210
211       Examples:
212

int QPoint::y () const

214       Returns the y coordinate of the point.
215
216       See also setY() and x().
217
218       Examples:
219

bool operator!= ( const QPoint & p1, const QPoint & p2 )

222       Returns TRUE if p1 and p2 are not equal; otherwise returns FALSE.
223

const QPoint operator* ( const QPoint & p, int c )

225       Returns the QPoint formed by multiplying both components of p by c.
226

const QPoint operator* ( int c, const QPoint & p )

228       This is an overloaded member function, provided for convenience. It
229       behaves essentially like the above function.
230
231       Returns the QPoint formed by multiplying both components of p by c.
232

const QPoint operator* ( const QPoint & p, double c )

234       This is an overloaded member function, provided for convenience. It
235       behaves essentially like the above function.
236
237       Returns the QPoint formed by multiplying both components of p by c.
238
239       Note that the result is truncated because points are held as integers.
240

const QPoint operator* ( double c, const QPoint & p )

242       This is an overloaded member function, provided for convenience. It
243       behaves essentially like the above function.
244
245       Returns the QPoint formed by multiplying both components of p by c.
246
247       Note that the result is truncated because points are held as integers.
248

const QPoint operator+ ( const QPoint & p1, const QPoint & p2 )

250       Returns the sum of p1 and p2; each component is added separately.
251

const QPoint operator- ( const QPoint & p1, const QPoint & p2 )

253       Returns p2 subtracted from p1; each component is subtracted separately.
254

const QPoint operator- ( const QPoint & p )

256       This is an overloaded member function, provided for convenience. It
257       behaves essentially like the above function.
258
259       Returns the QPoint formed by changing the sign of both components of p,
260       equivalent to QPoint(0,0) - p.
261

const QPoint operator/ ( const QPoint & p, int c )

263       Returns the QPoint formed by dividing both components of p by c.
264

const QPoint operator/ ( const QPoint & p, double c )

266       This is an overloaded member function, provided for convenience. It
267       behaves essentially like the above function.
268
269       Returns the QPoint formed by dividing both components of p by c.
270
271       Note that the result is truncated because points are held as integers.
272

QDataStream & operator<< ( QDataStream & s, const QPoint & p )

274       Writes point p to the stream s and returns a reference to the stream.
275
276       See also Format of the QDataStream operators.
277

bool operator== ( const QPoint & p1, const QPoint & p2 )

279       Returns TRUE if p1 and p2 are equal; otherwise returns FALSE.
280

QDataStream & operator>> ( QDataStream & s, QPoint & p )

282       Reads a QPoint from the stream s into point p and returns a reference
283       to the stream.
284
285       See also Format of the QDataStream operators.
286
287

SEE ALSO

289       http://doc.trolltech.com/qpoint.html
290       http://www.trolltech.com/faq/tech.html
291
293       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
294       license file included in the distribution for a complete license
295       statement.
296

AUTHOR

298       Generated automatically from the source code.
299

BUGS

301       If you find a bug in Qt, please report it as described in
302       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
303       help you. Thank you.
304
305       The definitive Qt documentation is provided in HTML format; it is
306       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
307       web browser. This man page is provided as a convenience for those users
308       who prefer man pages, although this format is not officially supported
309       by Trolltech.
310
311       If you find errors in this manual page, please report them to qt-
312       bugs@trolltech.com.  Please include the name of the manual page
313       (qpoint.3qt) and the Qt version (3.3.8).
314
315
316
317Trolltech AS                    2 February 2007                    QPoint(3qt)
Impressum