Eneboo - Documentación para desarrolladores
Métodos públicos | Amigas | Funciones relacionadas
Referencia de la Clase QPoint

The QPoint class defines a point in the plane. Más...

#include <qpoint.h>

Lista de todos los miembros.

Métodos públicos

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

Amigas

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

Funciones relacionadas

(Observar que estas no son funciones miembro.)

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

Descripción detallada

The QPoint class defines a point in the plane.

A point is specified by an x coordinate and a y coordinate.

The coordinate type is QCOORD (a 32-bit integer). The minimum value of QCOORD is QCOORD_MIN (-2147483648) and the maximum value is QCOORD_MAX (2147483647).

The coordinates are accessed by the functions x() and y(); they can be set by setX() and setY() or by the reference functions rx() and ry().

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

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

A QPoint can also be used as a vector. Addition and subtraction of QPoints are defined as for vectors (each component is added separately). You can divide or multiply a QPoint by an int or a double. The function manhattanLength() gives an inexpensive approximation of the length of the QPoint interpreted as a vector.

Example:

        //QPoint oldPos is defined somewhere else
        MyWidget::mouseMoveEvent( QMouseEvent *e )
        {
            QPoint vector = e->pos() - oldPos;
            if ( vector.manhattanLength() > 3 )
            ... //mouse has moved more than 3 pixels since oldPos
        }

QPoints can be compared for equality or inequality, and they can be written to and read from a QStream.

Ver también:
QPointArray QSize, QRect

Documentación del constructor y destructor

QPoint::QPoint ( ) [inline]

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

QPoint::QPoint ( int  xpos,
int  ypos 
) [inline]

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

QPoint::QPoint ( )
QPoint::QPoint ( int  xpos,
int  ypos 
)

Documentación de las funciones miembro

bool QPoint::isNull ( ) const [inline]

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

bool QPoint::isNull ( ) const
int QPoint::manhattanLength ( ) const
int QPoint::manhattanLength ( ) const

Returns the sum of the absolute values of x() and y(), traditionally known as the "Manhattan length" of the vector from the origin to the point. The tradition arises because such distances apply to travelers who can only travel on a rectangular grid, like the streets of Manhattan.

This is a useful, and quick to calculate, approximation to the true length: sqrt(pow(x(),2)+pow(y(),2)).

QPoint & QPoint::operator*= ( int  c) [inline]

Multiplies this point's x and y by c, and returns a reference to this point.

Example:

        QPoint p( -1, 4 );
        p *= 2;            // p becomes (-2,8)
QPoint & QPoint::operator*= ( double  c) [inline]
QPoint& QPoint::operator*= ( int  c)
QPoint& QPoint::operator*= ( double  c)
QPoint & QPoint::operator+= ( const QPoint p) [inline]

Adds point p to this point and returns a reference to this point.

Example:

        QPoint p(  3, 7 );
        QPoint q( -1, 4 );
        p += q;            // p becomes (2,11)
QPoint& QPoint::operator+= ( const QPoint p)
QPoint & QPoint::operator-= ( const QPoint p) [inline]

Subtracts point p from this point and returns a reference to this point.

Example:

        QPoint p(  3, 7 );
        QPoint q( -1, 4 );
        p -= q;            // p becomes (4,3)
QPoint& QPoint::operator-= ( const QPoint p)
QPoint& QPoint::operator/= ( int  c)
QPoint & QPoint::operator/= ( int  c) [inline]

Divides both x and y by c, and returns a reference to this point.

Example:

        QPoint p( -2, 8 );
        p /= 2;            // p becomes (-1,4)
QPoint& QPoint::operator/= ( double  c)
QPoint & QPoint::operator/= ( double  c) [inline]
QCOORD& QPoint::rx ( )
QCOORD & QPoint::rx ( ) [inline]

Returns a reference to the x coordinate of the point.

Using a reference makes it possible to directly manipulate x.

Example:

        QPoint p( 1, 2 );
        p.rx()--;         // p becomes (0, 2)
Ver también:
ry()
QCOORD & QPoint::ry ( ) [inline]

Returns a reference to the y coordinate of the point.

Using a reference makes it possible to directly manipulate y.

Example:

        QPoint p( 1, 2 );
        p.ry()++;         // p becomes (1, 3)
Ver también:
rx()
QCOORD& QPoint::ry ( )
void QPoint::setX ( int  x) [inline]

Sets the x coordinate of the point to x.

Ver también:
x() setY()
void QPoint::setX ( int  x)
void QPoint::setY ( int  y)
void QPoint::setY ( int  y) [inline]

Sets the y coordinate of the point to y.

Ver también:
y() setX()
int QPoint::x ( ) const [inline]

Returns the x coordinate of the point.

Ver también:
setX() y()
int QPoint::x ( ) const
int QPoint::y ( ) const
int QPoint::y ( ) const [inline]

Returns the y coordinate of the point.

Ver también:
setY() x()

Documentación de las funciones relacionadas y clases amigas

const QPoint operator [related]

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

const QPoint operator [related]

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

Note that the result is truncated because points are held as integers.

const QPoint operator [related]

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

Note that the result is truncated because points are held as integers.

const QPoint operator [related]

Returns the QPoint formed by changing the sign of both components of p, equivalent to {QPoint(0,0) - p}.

const QPoint operator [related]

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

Note that the result is truncated because points are held as integers.

bool operator!= ( const QPoint p1,
const QPoint p2 
) [friend]

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

bool operator!= ( const QPoint p1,
const QPoint p2 
) [friend]
const QPoint operator* ( double  c,
const QPoint p 
) [friend]
const QPoint operator* ( const QPoint p,
int  c 
) [friend]
const QPoint operator* ( int  c,
const QPoint p 
) [friend]
const QPoint operator* ( const QPoint p,
double  c 
) [friend]
const QPoint operator* ( double  c,
const QPoint p 
) [friend]
const QPoint operator* ( const QPoint p,
int  c 
) [friend]

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

const QPoint operator* ( int  c,
const QPoint p 
) [friend]
const QPoint operator* ( const QPoint p,
double  c 
) [friend]
const QPoint operator+ ( const QPoint p1,
const QPoint p2 
) [friend]

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

const QPoint operator+ ( const QPoint p1,
const QPoint p2 
) [friend]
const QPoint operator- ( const QPoint p) [friend]
const QPoint operator- ( const QPoint p) [friend]
const QPoint operator- ( const QPoint p1,
const QPoint p2 
) [friend]

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

const QPoint operator- ( const QPoint p1,
const QPoint p2 
) [friend]
const QPoint operator/ ( const QPoint p,
int  c 
) [friend]

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

const QPoint operator/ ( const QPoint p,
int  c 
) [friend]
const QPoint operator/ ( const QPoint p,
double  c 
) [friend]
const QPoint operator/ ( const QPoint p,
double  c 
) [friend]
QDataStream & operator<< ( QDataStream s,
const QPoint p 
) [related]

Writes point p to the stream s and returns a reference to the stream.

Ver también:
Format of the QDataStream operators
bool operator== ( const QPoint p1,
const QPoint p2 
) [friend]
bool operator== ( const QPoint p1,
const QPoint p2 
) [friend]

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

QDataStream & operator>> ( QDataStream s,
QPoint p 
) [related]

Reads a QPoint from the stream s into point p and returns a reference to the stream.

Ver también:
Format of the QDataStream operators

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'