The QPointF 类使用浮点精度定义平面点。 更多...
| 头: | #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 ) |
The QPointF 类使用浮点精度定义平面点。
点是通过 X 坐标和 Y 坐标指定,可以访问使用 x () 和 y () 函数。 使用浮点数指定点坐标以提高精度。 isNull () function returns true if both x and y are set to 0.0. The coordinates can be set (or altered) using the setX () 和 setY () 函数,或另外的 rx () 和 ry () 函数返回坐标引用 (允许直接操纵)。
给定点 p ,下列语句全部等效:
QPointF p; p.setX(p.x() + 1.0); p += QPointF(1.0, 0.0); p.rx()++;
A
QPointF
对象还可以用作向量:有为向量 (每个分量各自相加) 定义加法和减法。
QPointF
对象也可以除以或乘以
int
或
qreal
.
此外, QPointF 类提供构造函数转换 QPoint 对象成 QPointF 对象,和相应 toPoint () 函数返回 QPoint 副本为 this 点。最后, QPointF 对象可以被流化及比较。
构造 null 点,即具有坐标 (0.0, 0.0)
另请参阅 isNull ().
构造副本为给定 point .
另请参阅 toPoint ().
构造点采用给定坐标 ( x , y ).
Returns true if both the x and y coordinates are set to +0.0; otherwise returns false.
注意: 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.
返回绝对值的和对于 x () 和 y (),传统上称为从原点到点的 "曼哈顿长度" 向量。
该函数在 Qt 4.6 引入。
另请参阅 QPoint::manhattanLength ().
返回此点的 X 坐标引用。
使用引用使之可能直接操纵 X。例如:
QPointF p(1.1, 2.5); p.rx()--; // p becomes (0.1, 2.5)
返回此点的 Y 坐标引用。
使用引用使之可能直接操纵 Y。例如:
QPointF p(1.1, 2.5); p.ry()++; // p becomes (1.1, 3.5)
将此点的 X 坐标设为给定 x 坐标。
将此点的 Y 坐标设为给定 y 坐标。
将此点的坐标舍入到最近整数,并返回 QPoint 对象具有舍入坐标。
另请参阅 QPointF ().
Returns the x-coordinate of this point.
Returns the y-coordinate of this point.
将此点的坐标乘以给定 factor ,并返回此点的引用。例如:
QPointF p(-1.1, 4.1); p *= 2.5; // p becomes (-2.75, 10.25)
另请参阅 operator/= ().
添加给定 point 到此点并返回此点的引用。例如:
QPointF p( 3.1, 7.1); QPointF q(-1.0, 4.1); p += q; // p becomes (2.1, 11.2)
另请参阅 operator-= ().
减去给定 point 从此点并返回此点的引用。例如:
QPointF p( 3.1, 7.1); QPointF q(-1.0, 4.1); p -= q; // p becomes (4.1, 3.0)
另请参阅 operator+= ().
X 和 Y 两者除以给定 divisor ,并返回此点的引用。例如:
QPointF p(-2.75, 10.25); p /= 2.5; // p becomes (-1.1, 4.1)
另请参阅 operator*= ().
返回 true 若 p1 不等于 p2 ;否则返回 false。
这是重载函数。
返回副本为给定 point ,乘以给定 factor .
返回副本为给定 point ,乘以给定 factor .
另请参阅 QPointF::operator*= ().
返回 QPointF 对象是和对于给定点 p1 and p2 ;分别相加各分量。
另请参阅 QPointF::operator+= ().
返回 QPointF 对象的形成是通过减去 p2 from p1 ;分别减去各分量。
另请参阅 QPointF::operator-= ().
这是重载函数。
返回 QPointF 对象的形成是通过改变 2 分量的符号为给定 point .
相当于
QPointF(0,0) - point
.
返回 QPointF 形成对象通过除 2 分量为给定 point 通过给定 divisor .
另请参阅 QPointF::operator/= ().
写入给定 point 到给定 stream 并返回流引用。
另请参阅 序列化 Qt 数据类型 .
返回 true 若 p1 等于 p2 ;否则返回 false。
读取点从给定 stream 进给定 point 并返回流引用。
另请参阅 序列化 Qt 数据类型 .