QPoint Class
The QPoint class defines a point in the plane using integer precision. More...
Header: | #include <QPoint> |
qmake: | QT += core |
Note: All functions in this class are reentrant.
Public Functions
CGPoint | toCGPoint() const |
Related Non-Members
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 isNull() function returns true
if both x and y are set to 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:
QPoint p; p.setX(p.x() + 1); p += QPoint(1, 0); p.rx()++;
A QPoint object can also be used as a vector: Addition and subtraction are defined as for vectors (each component is added separately). A QPoint object can also be divided or multiplied by an int
or a qreal
.
In addition, the QPoint class provides the manhattanLength() function which gives an inexpensive approximation of the length of the QPoint object interpreted as a vector. Finally, QPoint objects can be streamed as well as compared.
See also QPointF and QPolygon.
Member Function Documentation
CGPoint QPoint::toCGPoint() const
Creates a CGPoint from a QPoint.
This function was introduced in Qt 5.8.
See also QPointF::fromCGPoint().
Related Non-Members
bool QPoint::operator!=(const int &p1, const int &p2)
Returns true
if p1 is not equal to p2; otherwise returns false. Two pairs compare as not equal if their first
data members are not equal or if their second
data members are not equal.
This function requires the T1 and T2 types to have an implementation of operator==()
.
This function was introduced in Qt 5.0.
bool QPoint::operator==(const int &p1, const int &p2)
Returns true
if p1 is equal to p2; otherwise returns false
. Two pairs compare equal if their first
data members compare equal and if their second
data members compare equal.
This function requires the T1 and T2 types to have an implementation of operator==()
.
This function was introduced in Qt 5.0.