|  | Home · All Classes · Main Classes · Annotated · Grouped Classes · Functions |

# QPointF Class Reference

The QPointF class provides a point object that uses floating point coordinates for accuracy. More...

    #include <QPointF>

Part of the QtCore module.

- List of all members, including inherited members

### Public Functions

- QPointF ()
- QPointF ( const QPoint & point )
- QPointF ( qreal x, qreal y )
- bool isNull () const
- qreal & rx ()
- qreal & ry ()
- void setX ( qreal x )
- void setY ( qreal y )
- QPoint toPoint () const
- qreal x () const
- qreal y () const
- QPointF & operator*= ( qreal factor )
- QPointF & operator+= ( const QPointF & other )
- QPointF & operator-= ( const QPointF & other )
- QPointF & operator/= ( qreal factor )

### Related Non-Members

- bool operator!= ( const QPointF & point1, const QPointF & point2 )
- const QPointF operator* ( const QPointF & point, qreal factor )
- const QPointF operator* ( qreal factor, const QPointF & point )
- const QPointF operator+ ( const QPointF & point, const QPointF & other )
- const QPointF operator- ( const QPointF & point, const QPointF & other )
- const QPointF operator- ( const QPointF & point )
- const QPointF operator/ ( const QPointF & point, qreal factor )
- QDataStream & operator<< ( QDataStream & s, const QPointF & p )
- bool operator== ( const QPointF & point1, const QPointF & point2 )
- QDataStream & operator>> ( QDataStream & s, QPointF & p )

## Detailed Description

The QPointF class provides a point object that uses floating point coordinates for accuracy.

A QPointF describes a point on a two-dimensional surface. The coordinates of the point are specified using floating point numbers for accuracy. QPoint provides points with integer accuracy.

Convenience functions are provided for reading and writing the individual coordinates used to define the point: x(), y(), setX(), and setY(). QPointF also provides support for the standard arithmetic operators, treating each point as a vector from the origin.

See also QPolygonF, QSizeF, QRectF, and QPoint.

## Member Function Documentation

### QPointF::QPointF ()

Constructs a null point.

See also isNull().

### QPointF::QPointF ( const QPoint & point )

Copy constructor. Constructs a point using the values of the point specified.

### QPointF::QPointF ( qreal x, qreal y )

Constructs a point with coordinates specified by x and y.

### bool QPointF::isNull () const

Returns true if the point is null; otherwise returns false.

A point is considered to be null if both the x- and y-coordinates are equal to zero.

### qreal & QPointF::rx ()

Returns a reference to the x-coordinate of the point.

See also ry() and setX().

### qreal & QPointF::ry ()

Returns a reference to the y-coordinate of the point.

See also rx() and setY().

### void QPointF::setX ( qreal x )

Sets the x-coordinate of the point to the value specified by x.

See also setY(), x(), and rx().

### void QPointF::setY ( qreal y )

Sets the y-coordinate of the point to the value specified by y.

See also setX(), y(), and ry().

### QPoint QPointF::toPoint () const

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

### qreal QPointF::x () const

Returns the x-coordinate of the point.

See also setX() and y().

### qreal QPointF::y () const

Returns the y-coordinate of the point.

See also setY() and x().

### QPointF & QPointF::operator*= ( qreal factor )

Multiplies the coordinates of this point by the given scale factor, and returns a reference to this point with the new coordinates. This is equivalent to scalar multiplication of a vector.

See also operator*() and operator/=().

### QPointF & QPointF::operator+= ( const QPointF & other )

Adds the coordinates of this point to the corresponding coordinates of the other point, and returns a reference to this point with the new coordinates. This is equivalent to vector addition.

See also operator+() and operator-=().

### QPointF & QPointF::operator-= ( const QPointF & other )

Subtracts the coordinates of the other point from the corresponding coordinates of this point, and returns a reference to this point with the new coordinates. This is equivalent to vector subtraction.

See also operator-() and operator+=().

### QPointF & QPointF::operator/= ( qreal factor )

Divides the coordinates of this point by the given scale factor, and returns a references to this point with the new coordinates. This is equivalent to scalar division of a vector.

See also operator*().

## Related Non-Members

### bool operator!= ( const QPointF & point1, const QPointF & point2 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns true if point1 is not equal to point2; otherwise returns false.

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Multiplies the coordinates of the point by the given scale factor, and returns a point with the new coordinates. (Scalar multiplication of a vector.)

See also operator/().

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Multiplies the coordinates of the point by the given scale factor, and returns a point with the new coordinates. (Scalar multiplication of a vector.)

See also operator/().

### const QPointF operator+ ( const QPointF & point, const QPointF & other )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Adds the coordinates of the point to the corresponding coordinates of the other point, and returns a point with the new coordinates. (Vector addition.)

See also operator-().

### const QPointF operator- ( const QPointF & point, const QPointF & other )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Subtracts the coordinates of the other point from the corresponding coordinates of the given point, and returns a point with the new coordinates. (Vector subtraction.)

See also operator+().

### const QPointF operator- ( const QPointF & point )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Negates the coordinates of the point, and returns a point with the new coordinates. (Inversion).

### const QPointF operator/ ( const QPointF & point, qreal factor )

Divides the coordinates of the point by the given scale factor, and returns a point with the new coordinates. (Scalar division of a vector.)

See also operator*().

### QDataStream & operator<< ( QDataStream & s, const QPointF & p )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

See also Format of the QDataStream operators.

### bool operator== ( const QPointF & point1, const QPointF & point2 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns true if point1 is equal to point2; otherwise returns false.

Two points are equal to each other if both x-coordinates and both y-coordinates are the same.

### QDataStream & operator>> ( QDataStream & s, QPointF & p )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

See also Format of the QDataStream operators.