
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQPointF class defines a point in the plane using floating point precision.More...
| Header: | #include <QPointF> |
| QPointF() | |
| QPointF(const QPoint & point) | |
| QPointF(qreal x, qreal y) | |
| bool | isNull() const |
| qreal | manhattanLength() 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 & point) |
| QPointF & | operator-=(const QPointF & point) |
| QPointF & | operator/=(qreal divisor) |
| bool | operator!=(const QPointF & p1, const QPointF & p2) |
| const QPointF | operator*(qreal factor, const QPointF & point) |
| const QPointF | operator*(const QPointF & point, qreal factor) |
| const QPointF | operator+(const QPointF & p1, const QPointF & p2) |
| const QPointF | operator-(const QPointF & p1, const QPointF & p2) |
| const QPointF | operator-(const QPointF & point) |
| const QPointF | operator/(const QPointF & point, qreal divisor) |
| QDataStream & | operator<<(QDataStream & stream, const QPointF & point) |
| bool | operator==(const QPointF & p1, const QPointF & p2) |
| QDataStream & | operator>>(QDataStream & stream, QPointF & point) |
TheQPointF class defines a point in the plane using floating point precision.
A point is specified by a x coordinate and an y coordinate which can be accessed using thex() andy() functions. The coordinates of the point are specified using floating point numbers for accuracy. TheisNull() function returns true if both x and y are set to 0.0. The coordinates can be set (or altered) using thesetX() andsetY() functions, or alternatively therx() andry() functions which return references to the coordinates (allowing direct manipulation).
Given a pointp, the following statements are all equivalent:
AQPointF object can also be used as a vector: Addition and subtraction are defined as for vectors (each component is added separately). AQPointF object can also be divided or multiplied by anint or aqreal.
In addition, theQPointF class provides a constructor converting aQPoint object into aQPointF object, and a correspondingtoPoint() function which returns aQPoint copy ofthis point. Finally,QPointF objects can be streamed as well as compared.
Constructs a null point, i.e. with coordinates (0.0, 0.0)
See alsoisNull().
Constructs a copy of the givenpoint.
See alsotoPoint().
Constructs a point with the given coordinates (x,y).
Returns true if both the x and y coordinates are set to +0.0; otherwise returns false.
Note:Since this function treats +0.0 and -0.0 differently, points with zero-valued coordinates where either or both values have a negative sign are not defined to be null points.
Returns the sum of the absolute values ofx() andy(), traditionally known as the "Manhattan length" of the vector from the origin to the point.
This function was introduced in Qt 4.6.
See alsoQPoint::manhattanLength().
Returns a reference to the x coordinate of this point.
Using a reference makes it possible to directly manipulate x. For example:
QPointF p(1.1,2.5); p.rx()--;// p becomes (0.1, 2.5)
Returns a reference to the y coordinate of this point.
Using a reference makes it possible to directly manipulate y. For example:
QPointF p(1.1,2.5);p.ry()++;// p becomes (1.1, 3.5)
Sets the x coordinate of this point to the givenx coordinate.
Sets the y coordinate of this point to the giveny coordinate.
Rounds the coordinates of this point to the nearest integer, and returns aQPoint object with the rounded coordinates.
See alsoQPointF().
Returns the x-coordinate of this point.
Returns the y-coordinate of this point.
Multiplies this point's coordinates by the givenfactor, and returns a reference to this point. For example:
QPointF p(-1.1,4.1);p*=2.5;// p becomes (-2.75, 10.25)
See alsooperator/=().
Adds the givenpoint to this point and returns a reference to this point. For example:
See alsooperator-=().
Subtracts the givenpoint from this point and returns a reference to this point. For example:
See alsooperator+=().
Divides both x and y by the givendivisor, and returns a reference to this point. For example:
QPointF p(-2.75,10.25);p/=2.5;// p becomes (-1.1, 4.1)
See alsooperator*=().
Returns true ifp1 is not equal top2; otherwise returns false.
This is an overloaded function.
Returns a copy of the givenpoint, multiplied by the givenfactor.
Returns a copy of the givenpoint, multiplied by the givenfactor.
See alsoQPointF::operator*=().
Returns aQPointF object that is the sum of the given points,p1 andp2; each component is added separately.
See alsoQPointF::operator+=().
Returns aQPointF object that is formed by subtractingp2 fromp1; each component is subtracted separately.
See alsoQPointF::operator-=().
This is an overloaded function.
Returns aQPointF object that is formed by changing the sign of both components of the givenpoint.
Equivalent toQPointF(0,0) - point.
Returns theQPointF object formed by dividing both components of the givenpoint by the givendivisor.
See alsoQPointF::operator/=().
Writes the givenpoint to the givenstream and returns a reference to the stream.
See alsoSerializing Qt Data Types.
Returns true ifp1 is equal top2; otherwise returns false.
Reads a point from the givenstream into the givenpoint and returns a reference to the stream.
See alsoSerializing Qt Data Types.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.