QPointF Class
The QPointF class defines a point in the plane using floating point precision. More…
| Header | #include <QPointF> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
List of all members, including inherited members
Public Functions
| QPointF() | |
| QPointF(const QPoint &p) | |
| QPointF(double xpos, double ypos) | |
| bool | isNull() const |
| double | x() const |
| double | y() const |
| void | setX(double x) |
| void | setY(double y) |
| double & | rx() |
| double & | ry() |
| double | manhattanLength() const |
| QPointF | transposed() const |
| QPoint | toPoint() const |
| QPointF & | operator+=(const QPointF &p) |
| QPointF & | operator-=(const QPointF &p) |
| QPointF & | operator*=(double f) |
| QPointF & | operator/=(double d) |
Static Public Members
| double | dotProduct(const QPointF &a, const QPointF &b) |
Detailed Description
A point is specified by an x coordinate and a y coordinate, both stored as double. Use QPoint for integer coordinates.
Equality comparison is fuzzy: two coordinates are considered equal if they are equal within the precision of double, as determined by qFuzzyCompare() and qFuzzyIsNull().
Differences from Qt
Coordinates are always double, which is what qreal is in Nt. There are no platform conversions such as toCGPoint().
Member Function Documentation
QPointF::QPointF()
Constructs a null point, that is, a point with coordinates (0.0, 0.0).
See also isNull().
QPointF::QPointF(const QPoint &p)
Constructs a copy of the given integer point p.
See also toPoint() and QPoint::toPointF().
QPointF::QPointF(double xpos, double ypos)
Constructs a point with coordinates (xpos, ypos).
double QPointF::dotProduct(const QPointF &a, const QPointF &b)
Returns the dot product of a and b.
bool QPointF::isNull() const
Returns true if both the x and y coordinates are fuzzily equal to 0; otherwise returns false.
double QPointF::manhattanLength() const
Returns the sum of the absolute values of x() and y(), the distance of the point from the origin measured along the axes.
QPointF & QPointF::operator*=(double f)
Multiplies this point's coordinates by the given factor f and returns a reference to this point.
QPointF & QPointF::operator+=(const QPointF &p)
Adds the given p to this point and returns a reference to this point.
QPointF & QPointF::operator-=(const QPointF &p)
Subtracts the given p from this point and returns a reference to this point.
QPointF & QPointF::operator/=(double d)
Divides both coordinates of this point by the given divisor d and returns a reference to this point.
double & QPointF::rx()
Returns a reference to the x coordinate of this point, allowing it to be modified directly.
double & QPointF::ry()
Returns a reference to the y coordinate of this point, allowing it to be modified directly.
void QPointF::setX(double x)
Sets the x coordinate of this point to the given x coordinate.
void QPointF::setY(double y)
Sets the y coordinate of this point to the given y coordinate.
QPoint QPointF::toPoint() const
Returns a QPoint with each coordinate rounded to the nearest integer.
See also QPoint::toPointF().
QPointF QPointF::transposed() const
Returns a point with the x and y coordinates exchanged.
See also QPoint::transposed().
double QPointF::x() const
Returns the x coordinate of this point.
double QPointF::y() const
Returns the y coordinate of this point.