Homepage > Man Pages > Category > Subroutines

Homepage > Man Pages > Name > Q# qpoint

## man page of qpoint

### qpoint: Defines a point in the plane

Homepage > Man Pages > Name > Q

## NAME

QPoint- Defines a point in the plane## SYNOPSIS

#include <qpoint.h>Public Members QPoint()QPoint( int xpos, int ypos )bool isNull() constint x() constint y() constvoid setX( int x )void setY( int y )int manhattanLength() constQCOORD & rx()QCOORD & ry()QPoint & operator+=( const QPoint & p )QPoint & operator-=( const QPoint & p )QPoint & operator*=( int c )QPoint & operator*=( double c )QPoint & operator/=( int c )QPoint & operator/=( double c )## RELATED FUNCTION DOCUMENTATION

bool operator==( const QPoint & p1, const QPoint & p2 )bool operator!=( const QPoint & p1, const QPoint & p2 )const QPoint operator+( const QPoint & p1, const QPoint & p2 )const QPoint operator-( const QPoint & p1, const QPoint & p2 )const QPoint operator*( const QPoint & p, int c )const QPoint operator*( int c, const QPoint & p )const QPoint operator*( const QPoint & p, double c )const QPoint operator*( double c, const QPoint & p )const QPoint operator-( const QPoint & p )const QPoint operator/( const QPoint & p, int c )const QPoint operator/( const QPoint & p, double c )QDataStream & operator<<( QDataStream & s, const QPoint & p )QDataStream & operator>>( QDataStream & s, QPoint & p )## DESCRIPTION

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 pointp, 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. See also QPointArray, QSize, QRect, Graphics Classes, and Image Processing Classes.## MEMBER FUNCTION DOCUMENTATION

QPOINT::QPOINT ()

Constructs a point with coordinates (0, 0) (isNull() returns TRUE).## QPOINT::QPOINT ( INT XPOS, INT YPOS )

Constructs a point with x valuexposand y valueypos.## BOOL QPOINT::ISNULL () CONST

Returns TRUE if both the x value and the y value are 0; otherwise returns FALSE.## 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 )

Multiplies this point's x and y byc, and returns a reference to this point. Example: QPoint p( -1, 4 ); p *= 2; // p becomes (-2,8)## QPOINT & QPOINT::OPERATOR*= ( DOUBLE C )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Multiplies this point's x and y byc, and returns a reference to this point. Example: QPoint p( -1, 4 ); p *= 2.5; // p becomes (-3,10) Note that the result is truncated because points are held as integers.QPOINT & QPOINT::OPERATOR+= ( CONST QPOINT & P )

Adds pointpto 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 )

Subtracts pointpfrom 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/= ( INT C )

Divides both x and y byc, and returns a reference to this point. Example: QPoint p( -2, 8 ); p /= 2; // p becomes (-1,4)## QPOINT & QPOINT::OPERATOR/= ( DOUBLE C )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Divides both x and y byc, and returns a reference to this point. Example: QPoint p( -3, 10 ); p /= 2.5; // p becomes (-1,4) Note that the result is truncated because points are held as integers.## QCOORD & QPOINT::RX ()

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) See also ry().## QCOORD & QPOINT::RY ()

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) See also rx().VOID QPOINT::SETX ( INT X )

Sets the x coordinate of the point tox. See also x() and setY(). Example: t14/cannon.cpp.## VOID QPOINT::SETY ( INT Y )

Sets the y coordinate of the point toy. See also y() and setX(). Example: t14/cannon.cpp.## INT QPOINT::X () CONST

Returns the x coordinate of the point. See also setX() and y(). Examples:## INT QPOINT::Y () CONST

Returns the y coordinate of the point. See also setY() and x(). Examples:## RELATED FUNCTION DOCUMENTATION

## BOOL OPERATOR!= ( CONST QPOINT & P1, CONST QPOINT & P2 )

Returns TRUE ifp1andp2are not equal; otherwise returns FALSE.CONST QPOINT OPERATOR* ( CONST QPOINT & P, INT C )

Returns the QPoint formed by multiplying both components ofpbyc.## CONST QPOINT OPERATOR* ( INT C, CONST QPOINT & P )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Returns the QPoint formed by multiplying both components ofpbyc.## CONST QPOINT OPERATOR* ( CONST QPOINT & P, DOUBLE C )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Returns the QPoint formed by multiplying both components ofpbyc. Note that the result is truncated because points are held as integers.## CONST QPOINT OPERATOR* ( DOUBLE C, CONST QPOINT & P )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Returns the QPoint formed by multiplying both components ofpbyc. Note that the result is truncated because points are held as integers.## CONST QPOINT OPERATOR+ ( CONST QPOINT & P1, CONST QPOINT & P2 )

Returns the sum ofp1andp2; each component is added separately.## CONST QPOINT OPERATOR- ( CONST QPOINT & P1, CONST QPOINT & P2 )

Returnsp2subtracted fromp1; each component is subtracted separately.CONST QPOINT OPERATOR- ( CONST QPOINT & P )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Returns the QPoint formed by changing the sign of both components ofp, equivalent to QPoint(0,0) - p.## CONST QPOINT OPERATOR/ ( CONST QPOINT & P, INT C )

Returns the QPoint formed by dividing both components ofpbyc.## CONST QPOINT OPERATOR/ ( CONST QPOINT & P, DOUBLE C )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Returns the QPoint formed by dividing both components ofpbyc. Note that the result is truncated because points are held as integers.## QDATASTREAM & OPERATOR<< ( QDATASTREAM & S, CONST QPOINT & P )

Writes pointpto the streamsand returns a reference to the stream. See also Format of the QDataStream operators.## BOOL OPERATOR== ( CONST QPOINT & P1, CONST QPOINT & P2 )

Returns TRUE ifp1andp2are equal; otherwise returns FALSE.## QDATASTREAM & OPERATOR>> ( QDATASTREAM & S, QPOINT & P )

Reads a QPoint from the streamsinto pointpand returns a reference to the stream. See also Format of the QDataStream operators.SEE ALSO

//doc.trolltech.com/qpoint.html //www.trolltech.com/faq/tech.html## COPYRIGHT

Copyright 1992-2007 Trolltech ASA, //www.trolltech.com. See the license file included in the distribution for a complete license statement.## AUTHOR

Generated automatically from the source code.## BUGS

If you find a bug in Qt, please report it as described in //doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt- bugs@trolltech.com. Please include the name of the manual page (qpoint.3qt) and the Qt version (3.3.8). QPOINT(3)

Copyright © 2011–2018 by topics-of-interest.com . All rights reserved. Hosted by all-inkl.

Contact · Imprint · Privacy

Page generated in 27.70ms.

doomsdaydude.com | holzspalter.name | uhren.name