Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QPoint Class Reference

List of all members.

Detailed Description

The QPoint class defines a point in the plane using integer precision.

A point is specified by a x coordinate and an y coordinate which can be accessed using the x() and y() functions. The isNull() function returns true if both x and y are set to 0. The coordinates can be set (or altered) using the setX() and setY() functions, or alternatively the rx() and ry() functions which return references to the coordinates (allowing direct manipulation).

Given a point p, the following statements are all equivalent:

        QPoint p;

        p.setX(p.x() + 1);
        p += QPoint(1, 0);

A QPoint object can also be used as a vector: Addition and subtraction are defined as for vectors (each component is added separately). A QPoint object can also be divided or multiplied by an int or a qreal.

In addition, the QPoint class provides the manhattanLength() function which gives an inexpensive approximation of the length of the QPoint object interpreted as a vector. Finally, QPoint objects can be streamed as well as compared.

See also:
QPointF, QPolygon

Definition at line 31 of file qpoint.h.

Public Member Functions

bool isNull () const
int manhattanLength () const
QPointoperator*= (qreal c)
QPointoperator+= (const QPoint &p)
QPointoperator-= (const QPoint &p)
QPointoperator/= (qreal c)
 QPoint (int xpos, int ypos)
 QPoint ()
int & rx ()
int & ry ()
void setX (int x)
void setY (int y)
int x () const
int y () const

Private Attributes

int xp
int yp


bool operator!= (const QPoint &, const QPoint &)
const QPoint operator* (qreal, const QPoint &)
const QPoint operator* (const QPoint &, qreal)
const QPoint operator+ (const QPoint &, const QPoint &)
const QPoint operator- (const QPoint &)
const QPoint operator- (const QPoint &, const QPoint &)
const QPoint operator/ (const QPoint &, qreal)
bool operator== (const QPoint &, const QPoint &)

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &stream, const QPoint &point)
QDataStreamoperator>> (QDataStream &stream, QPoint &point)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index