 CopperSpice API  1.7.2
QPointF Class Reference

The QPointF class defines a point in the plane using floating point precision. More...

## Public Methods

QPointF ()

QPointF (const QPoint &p)

QPointF (qreal xPos, qreal yPos)

bool isNull () const

qreal manhattanLength () const

QPointF & operator*= (qreal c)

QPointF & operator+= (const QPointF &p)

QPointF & operator-= (const QPointF &p)

QPointF & operator/= (qreal c)

qrealrx ()

qrealry ()

void setX (qreal xPos)

void setY (qreal yPos)

QPoint toPoint () const

qreal x () const

qreal y () const

## Friends

bool operator!= (const QPointF &, const QPointF &)

const QPointF operator* (const QPointF &, qreal)

const QPointF operator* (qreal, const QPointF &)

const QPointF operator+ (const QPointF &, const QPointF &)

const QPointF operator- (const QPointF &)

const QPointF operator- (const QPointF &, const QPointF &)

const QPointF operator/ (const QPointF &, qreal)

bool operator== (const QPointF &, const QPointF &)

class QMatrix

class QTransform

## Related Functions

These are not member functions

QDataStreamoperator<< (QDataStream &stream, const QPointF &point)

QDataStreamoperator>> (QDataStream &stream, QPointF &point)

## Detailed Description

The QPointF class defines a point in the plane using floating point precision.

A point is specified by a x coordinate and an y coordinate which can be accessed using the x() and y() functions. The coordinates of the point are specified using floating point numbers for accuracy. The isNull() function returns true if both x and y are set to 0.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:

p.setX(p.x() + 1.0);
p += QPointF(1.0, 0.0);
p.rx()++;

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

In addition, the QPointF class provides a constructor converting a QPoint object into a QPointF object, and a corresponding toPoint() function which returns a QPoint copy of this point. Finally, QPointF objects can be streamed as well as compared.

QPoint, QPolygonF

## Constructor & Destructor Documentation

 QPointF::QPointF ( )
inline

Constructs a null point, i.e. with coordinates (0.0, 0.0)

isNull()
 QPointF::QPointF ( const QPoint & p )
inline

Constructs a copy of the given point.

toPoint()
 QPointF::QPointF ( qreal xPos, qreal yPos )
inline

Constructs a point with the given coordinates (x, y).

setX(), setY()

## Method Documentation

 bool QPointF::isNull ( ) const
inline

Returns true if both the x and y coordinates are set to +0.0, otherwise returns false.

Note
Since this function treats +0.0 and -0.0 differently, points with zero-valued coordinates where either or both values have a negative sign are not defined to be null points.
 qreal QPointF::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.

QPoint::manhattanLength()
 QPointF & QPointF::operator*= ( qreal c )
inline

Multiplies this point's coordinates by the given factor, and returns a reference to this point.

QPointF p(-1.1, 4.1);
p *= 2.5; // p becomes (-2.75, 10.25)
operator/=()
 QPointF & QPointF::operator+= ( const QPointF & p )
inline

Adds the given point to this point and returns a reference to this point.

QPointF p( 3.1, 7.1);
QPointF q(-1.0, 4.1);
p += q; // p becomes (2.1, 11.2)
operator-=()
 QPointF & QPointF::operator-= ( const QPointF & p )
inline

Subtracts the given point from this point and returns a reference to this point.

QPointF p( 3.1, 7.1);
QPointF q(-1.0, 4.1);
p -= q; // p becomes (4.1, 3.0)
operator+=()
 QPointF & QPointF::operator/= ( qreal c )
inline

Divides both x and y by the given divisor, and returns a reference to this point.

QPointF p(-2.75, 10.25);
p /= 2.5; // p becomes (-1.1, 4.1)
operator*=()
 qreal & QPointF::rx ( )
inline

Returns a reference to the x coordinate of this point. Using a reference makes it possible to directly modify x.

QPointF p(1.1, 2.5);
--(p.rx()); // p becomes (0.1, 2.5)
x(), setX()
 qreal & QPointF::ry ( )
inline

Returns a reference to the y coordinate of this point. Using a reference makes it possible to directly modify y.

QPointF p(1.1, 2.5);
++(p.ry()); // p becomes (1.1, 3.5)
y(), setY()
 void QPointF::setX ( qreal xPos )
inline

Sets the x coordinate of this point to the given xPos coordinate.

x(), setY()
 void QPointF::setY ( qreal yPos )
inline

Sets the y coordinate of this point to the given yPos coordinate.

y(), setX()
 QPoint QPointF::toPoint ( ) const
inline

Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rounded coordinates.

QPointF()
 qreal QPointF::x ( ) const
inline

Returns the x-coordinate of this point.

setX(), rx()
 qreal QPointF::y ( ) const
inline

Returns the y-coordinate of this point.

setY(), ry()

## Friends And Related Function Documentation

 bool operator!= ( const QPointF & p1, const QPointF & p2 )
friend

Returns true if p1 is not equal to p2, otherwise returns false.

 const QPointF operator* ( const QPointF & point, qreal factor )
friend

Returns a copy of the given point, multiplied by the given factor.

QPointF::operator*=()
 const QPointF operator* ( qreal factor, const QPointF & point )
friend

Returns a copy of the given point, multiplied by the given factor.

 const QPointF operator+ ( const QPointF & p1, const QPointF & p2 )
friend

Returns a QPointF object that is the sum of the given points, p1 and p2, each component is added separately.

QPointF::operator+=()
 const QPointF operator- ( const QPointF & point )
friend

Returns a QPointF object that is formed by changing the sign of both components of the given point.

Equivalent to QPointF(0,0) - point.

 const QPointF operator- ( const QPointF & p1, const QPointF & p2 )
friend

Returns a QPointF object that is formed by subtracting p2 from p1, each component is subtracted separately.

QPointF::operator-=()
 const QPointF operator/ ( const QPointF & point, qreal divisor )
friend

Returns the QPointF object formed by dividing both components of the given point by the given divisor.

QPointF::operator/=()
 QDataStream & operator<< ( QDataStream & stream, const QPointF & point )
related

Writes the given point to the given stream and returns a reference to the stream.

Refer to Serializing Data Types for additional information.

 bool operator== ( const QPointF & p1, const QPointF & p2 )
friend

Returns true if p1 is equal to p2, otherwise returns false.

 QDataStream & operator>> ( QDataStream & stream, QPointF & point )
related

Reads a point from the given stream into the given point and returns a reference to the stream.

Refer to Serializing Data Types for additional information.