![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore\reentrant More...
#include <qpoint.h>
Public Member Functions | |
constexpr | QPoint () noexcept |
Constructs a null point, i.e. | |
constexpr | QPoint (int xpos, int ypos) noexcept |
Constructs a point with the given coordinates (xpos, ypos). | |
constexpr bool | isNull () const noexcept |
Returns true if both the x and y coordinates are set to 0, otherwise returns false . | |
constexpr int | x () const noexcept |
Returns the x coordinate of this point. | |
constexpr int | y () const noexcept |
Returns the y coordinate of this point. | |
constexpr void | setX (int x) noexcept |
Sets the x coordinate of this point to the given x coordinate. | |
constexpr void | setY (int y) noexcept |
Sets the y coordinate of this point to the given y coordinate. | |
constexpr int | 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. | |
constexpr QPoint | transposed () const noexcept |
constexpr int & | rx () noexcept |
Returns a reference to the x coordinate of this point. | |
constexpr int & | ry () noexcept |
Returns a reference to the y coordinate of this point. | |
constexpr QPoint & | operator+= (const QPoint &p) |
Adds the given point to this point and returns a reference to this point. | |
constexpr QPoint & | operator-= (const QPoint &p) |
Subtracts the given point from this point and returns a reference to this point. | |
constexpr QPoint & | operator*= (float factor) |
Multiplies this point's coordinates by the given factor, and returns a reference to this point. | |
constexpr QPoint & | operator*= (double factor) |
Multiplies this point's coordinates by the given factor, and returns a reference to this point. | |
constexpr QPoint & | operator*= (int factor) |
Multiplies this point's coordinates by the given factor, and returns a reference to this point. | |
constexpr QPoint & | operator/= (qreal divisor) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Divides both x and y by the given divisor, and returns a reference to this point. | |
constexpr QPointF | toPointF () const noexcept |
Static Public Member Functions | |
static constexpr int | dotProduct (const QPoint &p1, const QPoint &p2) |
Friends | |
class | QRect |
constexpr bool | comparesEqual (const QPoint &p1, const QPoint &p2) noexcept |
constexpr QPoint | operator+ (const QPoint &p1, const QPoint &p2) noexcept |
Returns a QPoint object that is the sum of the given points, p1 and p2; each component is added separately. | |
constexpr QPoint | operator- (const QPoint &p1, const QPoint &p2) noexcept |
Returns a QPoint object that is formed by subtracting p2 from p1; each component is subtracted separately. | |
constexpr QPoint | operator* (const QPoint &p, float factor) |
Returns a copy of the given point multiplied by the given factor. | |
constexpr QPoint | operator* (const QPoint &p, double factor) |
Returns a copy of the given point multiplied by the given factor. | |
constexpr QPoint | operator* (const QPoint &p, int factor) noexcept |
Returns a copy of the given point multiplied by the given factor. | |
constexpr QPoint | operator* (float factor, const QPoint &p) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a copy of the given point multiplied by the given factor. | |
constexpr QPoint | operator* (double factor, const QPoint &p) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a copy of the given point multiplied by the given factor. | |
constexpr QPoint | operator* (int factor, const QPoint &p) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a copy of the given point multiplied by the given factor. | |
constexpr QPoint | operator+ (const QPoint &p) noexcept |
constexpr QPoint | operator- (const QPoint &p) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QPoint object that is formed by changing the sign of both components of the given point. | |
constexpr QPoint | operator/ (const QPoint &p, qreal c) |
Returns the QPoint formed by dividing both components of the given point by the given divisor. | |
template<std::size_t I, typename P, std::enable_if_t<(I< 2), bool > = true, std::enable_if_t< std::is_same_v< q20::remove_cvref_t< P >, QPoint >, bool > = true> | |
constexpr decltype(auto) | get (P &&p) noexcept |
Related Symbols | |
(Note that these are not member symbols.) | |
QDataStream & | operator<< (QDataStream &stream, const QPoint &point) |
Writes the given point to the given stream and returns a reference to the stream. | |
QDataStream & | operator>> (QDataStream &stream, QPoint &point) |
Reads a point from the given stream into the given point and returns a reference to the stream. | |
\inmodule QtCore
\reentrant
\compares equality \compareswith equality QPointF \endcompareswith
The QPoint class defines a point in the plane using integer precision.
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:
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.
|
inlineconstexprnoexcept |
Constructs a null point, i.e.
with coordinates (0, 0)
Definition at line 132 of file qpoint.h.
Referenced by QSwipeGestureRecognizer::reset().
|
inlineconstexprnoexcept |
|
inlinestaticconstexpr |
Returns the dot product of p1 and p2.
|
inlineconstexprnoexcept |
|
inlineconstexpr |
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.
For example:
This is a useful, and quick to calculate, approximation to the true length:
The tradition of "Manhattan length" arises because such distances apply to travelers who can only travel on a rectangular grid, like the streets of Manhattan.
|
inlineconstexpr |
Multiplies this point's coordinates by the given factor, and returns a reference to this point.
For example:
Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.
|
inlineconstexpr |
Multiplies this point's coordinates by the given factor, and returns a reference to this point.
Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.
|
inlineconstexpr |
Multiplies this point's coordinates by the given factor, and returns a reference to this point.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Divides both x and y by the given divisor, and returns a reference to this point.
For example:
Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
friend |
Returns a copy of the given point multiplied by the given factor.
Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.
Returns a copy of the given point multiplied by the given factor.
Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.
Returns a copy of the given point multiplied by the given factor.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a copy of the given point multiplied by the given factor.
Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a copy of the given point multiplied by the given factor.
Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a copy of the given point multiplied by the given factor.
Returns a QPoint object that is the sum of the given points, p1 and p2; each component is added separately.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QPoint object that is formed by changing the sign of both components of the given point.
Equivalent to {QPoint(0,0) - point}.
Returns a QPoint object that is formed by subtracting p2 from p1; each component is subtracted separately.
Returns the QPoint formed by dividing both components of the given point by the given divisor.
Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.
|
|