QPointF Class

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

Header: #include <QPointF>
qmake: QT += core

Note: All functions in this class are reentrant.

Public Functions

CGPoint toCGPoint() const

Static Public Members

QPointF fromCGPoint(CGPoint point)
bool operator!=(const int &p1, const int &p2)
bool operator==(const int &p1, const int &p2)

Detailed Description

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:


  QPointF p;

  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.

See also QPoint and QPolygonF.

Member Function Documentation

[static] QPointF QPointF::fromCGPoint(CGPoint point)

Creates a QRectF from CGPoint point.

This function was introduced in Qt 5.8.

See also toCGPoint().

CGPoint QPointF::toCGPoint() const

Creates a CGPoint from a QPointF.

This function was introduced in Qt 5.8.

See also fromCGPoint().

Related Non-Members

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

Returns true if p1 and p2 are not equal; otherwise returns false.

This function was introduced in Qt 5.0.

bool QPointF::operator==(const int &p1, const int &p2)

Returns true if p1 and p2 are equal; otherwise returns false.

This function was introduced in Qt 5.0.