QLine 类

QLine 类提供使用整数精度的 2D 向量。 更多...

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

公共函数

QLine (int x1 , int y1 , int x2 , int y2 )
QLine (const QPoint & p1 , const QPoint & p2 )
QLine ()
QPoint p1 () const
QPoint p2 () const
int x1 () const
int x2 () const
int y1 () const
int y2 () const
QPoint center () const
int dx () const
int dy () const
bool isNull () const
void setP1 (const QPoint & p1 )
void setP2 (const QPoint & p2 )
void setLine (int x1 , int y1 , int x2 , int y2 )
void setPoints (const QPoint & p1 , const QPoint & p2 )
void translate (const QPoint & offset )
void translate (int dx , int dy )
QLine translated (const QPoint & offset ) const
QLine translated (int dx , int dy ) const
bool operator!= (const QLine & line ) const
bool operator== (const QLine & line ) const
QDataStream & operator<< (QDataStream & stream , const QLine & line )
QDataStream & operator>> (QDataStream & stream , QLine & line )

详细描述

A QLine describes a finite length line (or a line segment) on a two-dimensional surface. The start and end points of the line are specified using integer point accuracy for coordinates. Use the QLineF constructor to retrieve a floating point copy.

The positions of the line's start and end points can be retrieved using the p1 (), x1 (), y1 (), p2 (), x2 (),和 y2 () 函数。 dx () 和 dy () functions return the horizontal and vertical components of the line. Use isNull () to determine whether the QLine represents a valid line or a null line.

Finally, the line can be translated a given offset using the translate () 函数。

另请参阅 QLineF , QPolygon ,和 QRect .

成员函数文档编制

QLine:: QLine ( int x1 , int y1 , int x2 , int y2 )

Constructs a line object that represents the line between ( x1 , y1 ) 和 ( x2 , y2 ).

QLine:: QLine (const QPoint & p1 , const QPoint & p2 )

构造的线条对象表示线条介于 p1 and p2 .

QLine:: QLine ()

构造 null 线条。

QPoint QLine:: p1 () const

返回线条的起始点。

另请参阅 setP1 (), x1 (), y1 (),和 p2 ().

QPoint QLine:: p2 () const

返回线的终点。

另请参阅 setP2 (), x2 (), y2 (),和 p1 ().

int QLine:: x1 () const

返回线条起始点的 X 坐标。

另请参阅 p1 ().

int QLine:: x2 () const

返回线终点的 X 坐标。

另请参阅 p2 ().

int QLine:: y1 () const

返回线条起始点的 Y 坐标。

另请参阅 p1 ().

int QLine:: y2 () const

返回线终点的 Y 坐标。

另请参阅 p2 ().

QPoint QLine:: center () const

Returns the center point of this line. This is equivalent to ( p1 () + p2 ()) / 2, except it will never overflow.

该函数在 Qt 5.8 引入。

int QLine:: dx () const

Returns the horizontal component of the line's vector.

另请参阅 dy ().

int QLine:: dy () const

Returns the vertical component of the line's vector.

另请参阅 dx ().

bool QLine:: isNull () const

返回 true if the line does not have distinct start and end points; otherwise returns false .

void QLine:: setP1 (const QPoint & p1 )

Sets the starting point of this line to p1 .

该函数在 Qt 4.4 引入。

另请参阅 setP2 () 和 p1 ().

void QLine:: setP2 (const QPoint & p2 )

Sets the end point of this line to p2 .

该函数在 Qt 4.4 引入。

另请参阅 setP1 () 和 p2 ().

void QLine:: setLine ( int x1 , int y1 , int x2 , int y2 )

Sets this line to the start in x1 , y1 and end in x2 , y2 .

该函数在 Qt 4.4 引入。

另请参阅 setP1 (), setP2 (), p1 (),和 p2 ().

void QLine:: setPoints (const QPoint & p1 , const QPoint & p2 )

Sets the start point of this line to p1 and the end point of this line to p2 .

该函数在 Qt 4.4 引入。

另请参阅 setP1 (), setP2 (), p1 (),和 p2 ().

void QLine:: translate (const QPoint & offset )

Translates this line by the given offset .

void QLine:: translate ( int dx , int dy )

这是重载函数。

Translates this line the distance specified by dx and dy .

QLine QLine:: translated (const QPoint & offset ) const

Returns this line translated by the given offset .

该函数在 Qt 4.4 引入。

QLine QLine:: translated ( int dx , int dy ) const

这是重载函数。

Returns this line translated the distance specified by dx and dy .

该函数在 Qt 4.4 引入。

bool QLine:: operator!= (const QLine & line ) const

返回 true 若给定 line is not the same as this line.

A line is different from another line if any of their start or end points differ, or the internal order of the points is different.

bool QLine:: operator== (const QLine & line ) const

返回 true 若给定 line 如同 this line.

A line is identical to another line if the start and end points are identical, and the internal order of the points is the same.

相关非成员

QDataStream & operator<< ( QDataStream & stream , const QLine & line )

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

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

QDataStream & operator>> ( QDataStream & stream , QLine & line )

Reads a line from the given stream 进给定 line 并返回流引用。

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