QPointF 类

QPointF class defines a point in the plane using floating point precision. 更多...

头: #include <QPointF>
qmake: QT += core

注意: 此类的所有函数 可重入 .

公共函数

QPointF ()
QPointF (const QPoint & point )
QPointF (qreal xpos , qreal ypos )
bool isNull () const
qreal manhattanLength () const
qreal & rx ()
qreal & ry ()
void setX (qreal x )
void setY (qreal y )
CGPoint toCGPoint () const
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 )

静态公共成员

qreal dotProduct (const QPointF & p1 , const QPointF & p2 )
QPointF fromCGPoint (CGPoint point )
bool operator!= (const QPointF & p1 , const QPointF & p2 )
const QPointF operator* (const QPointF & point , qreal factor )
const QPointF operator* (qreal factor , const QPointF & point )
const QPointF operator+ (const QPointF & p1 , const QPointF & p2 )
const QPointF operator+ (const QPointF & point )
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 )

详细描述

QPointF class defines a point in the plane using floating point precision.

点通过 X 坐标和 Y 坐标进行指定,可以访问使用 x () 和 y () functions. The coordinates of the point are specified using floating point numbers for accuracy. The isNull () 函数返回 true 若 X 和 Y 两者被设为 0.0。可以设置 (或变更) 坐标使用 setX () 和 setY () 函数,或另外的 rx () 和 ry () 函数返回坐标引用 (允许直接操纵)。

给定点 p ,下列语句全部等效:

QPointF p;
p.setX(p.x() + 1.0);
p += QPointF(1.0, 0.0);
p.rx()++;
					

A QPointF object can also be used as a vector: Addition and subtraction are defined as for vectors (each component is added separately). A QPointF object can also be divided or multiplied by an int qreal .

此外, QPointF class provides a constructor converting a QPoint object into a QPointF object, and a corresponding toPoint () 函数返回 QPoint 副本为 this point. Finally, QPointF 对象可以被流化及比较。

另请参阅 QPoint and QPolygonF .

成员函数文档编制

QPointF:: QPointF ()

构造 null 点,即具有坐标 (0.0, 0.0)

另请参阅 isNull ().

QPointF:: QPointF (const QPoint & point )

构造副本为给定 point .

另请参阅 toPoint ().

QPointF:: QPointF ( qreal xpos , qreal ypos )

构造点采用给定坐标 ( xpos , ypos ).

另请参阅 setX () 和 setY ().

[static] qreal QPointF:: dotProduct (const QPointF & p1 , const QPointF & p2 )

QPointF p( 3.1, 7.1);
QPointF q(-1.0, 4.1);
int lengthSquared = QPointF::dotProduct(p, q);   // lengthSquared becomes 26.01
					

返回点积为 p1 and p2 .

该函数在 Qt 5.1 引入。

[static] QPointF QPointF:: fromCGPoint ( CGPoint point )

创建 QRectF 从 CGPoint point .

该函数在 Qt 5.8 引入。

另请参阅 toCGPoint ().

bool QPointF:: isNull () const

返回 true 若 X 和 Y 坐标两者被设为 0.0 (忽略符号); 否则返回 false .

qreal QPointF:: manhattanLength () const

返回绝对值的和对于 x () 和 y (),传统上称为从原点到点的 "曼哈顿长度" 向量。

该函数在 Qt 4.6 引入。

另请参阅 QPoint::manhattanLength ().

qreal &QPointF:: rx ()

返回此点的 x 坐标引用。

使用引用使之可能直接操纵 X。例如:

 QPointF p(1.1, 2.5);
 p.rx()--;   // p becomes (0.1, 2.5)
					

另请参阅 x () 和 setX ().

qreal &QPointF:: ry ()

返回此点的 y 坐标引用。

使用引用使之可能直接操纵 Y。例如:

QPointF p(1.1, 2.5);
p.ry()++;   // p becomes (1.1, 3.5)
					

另请参阅 y () 和 setY ().

void QPointF:: setX ( qreal x )

将此点的 x 坐标设为给定 x 坐标。

另请参阅 x () 和 setY ().

void QPointF:: setY ( qreal y )

将此点的 y 坐标设为给定 y 坐标。

另请参阅 y () 和 setX ().

CGPoint QPointF:: toCGPoint () const

创建 CGPoint 从 QPointF .

该函数在 Qt 5.8 引入。

另请参阅 fromCGPoint ().

QPoint QPointF:: toPoint () const

将此点的坐标舍入到最近整数,并返回 QPoint 对象具有舍入坐标。

另请参阅 QPointF ().

qreal QPointF:: x () const

返回此点的 x 坐标。

另请参阅 setX () 和 rx ().

qreal QPointF:: y () const

返回此点的 y 坐标。

另请参阅 setY () 和 ry ().

QPointF &QPointF:: operator*= ( qreal factor )

将此点的坐标乘以给定 factor ,并返回此点的引用。例如:

QPointF p(-1.1, 4.1);
p *= 2.5;    // p becomes (-2.75, 10.25)
					

另请参阅 operator/= ().

QPointF &QPointF:: operator+= (const QPointF & point )

添加给定 point 到此点并返回此点的引用。例如:

QPointF p( 3.1, 7.1);
QPointF q(-1.0, 4.1);
p += q;    // p becomes (2.1, 11.2)
					

另请参阅 operator-= ().

QPointF &QPointF:: operator-= (const QPointF & point )

减去给定 point 从此点并返回此点的引用。例如:

QPointF p( 3.1, 7.1);
QPointF q(-1.0, 4.1);
p -= q;    // p becomes (4.1, 3.0)
					

另请参阅 operator+= ().

QPointF &QPointF:: operator/= ( qreal divisor )

X 和 Y 两者除以给定 divisor ,并返回此点的引用。例如:

QPointF p(-2.75, 10.25);
p /= 2.5;           // p becomes (-1.1, 4.1)
					

另请参阅 operator*= ().

相关非成员

bool operator!= (const QPointF & p1 , const QPointF & p2 )

返回 true if p1 不等于 p2 ;否则返回 false .

const QPointF operator* (const QPointF & point , qreal factor )

返回副本为给定 point , multiplied by the given factor .

另请参阅 QPointF::operator*= ().

const QPointF operator* ( qreal factor , const QPointF & point )

这是重载函数。

返回副本为给定 point , multiplied by the given factor .

const QPointF operator+ (const QPointF & p1 , const QPointF & p2 )

返回 QPointF 对象是和对于给定点 p1 and p2 ;分别相加各分量。

另请参阅 QPointF::operator+= ().

const QPointF operator+ (const QPointF & point )

返回 point 未经修改。

该函数在 Qt 5.0 引入。

const QPointF operator- (const QPointF & p1 , const QPointF & p2 )

返回 QPointF 对象的形成是通过减去 p2 from p1 ;分别减去各分量。

另请参阅 QPointF::operator-= ().

const QPointF operator- (const QPointF & point )

这是重载函数。

返回 QPointF 对象的形成是通过改变 2 分量的符号为给定 point .

相当于 QPointF(0,0) - point .

const QPointF operator/ (const QPointF & point , qreal divisor )

返回 QPointF object formed by dividing both components of the given point 通过给定 divisor .

另请参阅 QPointF::operator/= ().

QDataStream & operator<< ( QDataStream & stream , const QPointF & point )

写入给定 point 到给定 stream 并返回流引用。

另请参阅 序列化 Qt 数据类型 .

bool operator== (const QPointF & p1 , const QPointF & p2 )

返回 true if p1 等于 p2 ;否则返回 false .

QDataStream & operator>> ( QDataStream & stream , QPointF & point )

读取点从给定 stream 进给定 point 并返回流引用。

另请参阅 序列化 Qt 数据类型 .