QLine 類提供使用整數精度的 2D 嚮量。 更多...
| 頭: |
#include <QLine>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
|
| qmake: |
QT += core
|
此類 相等可比較 .
此類 相等可比較 with QLineF .
| QLine () | |
| QLine (const QPoint & p1 , const QPoint & p2 ) | |
| QLine (int x1 , int y1 , int x2 , int y2 ) | |
| 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 ) |
(從 6.4 起)
QLineF
|
toLineF () const |
| 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 & lhs , const QLine & rhs ) |
| QDataStream & | operator<< (QDataStream & stream , const QLine & line ) |
| bool | operator== (const QLine & lhs , const QLine & rhs ) |
| 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 .
[constexpr]
QLine::
QLine
()
構造 null 綫條。
[constexpr]
QLine::
QLine
(const
QPoint
&
p1
, const
QPoint
&
p2
)
構造的綫條對象錶示綫條介於 p1 and p2 .
[constexpr]
QLine::
QLine
(
int
x1
,
int
y1
,
int
x2
,
int
y2
)
Constructs a line object that represents the line between ( x1 , y1 ) 和 ( x2 , y2 ).
[constexpr]
QPoint
QLine::
p1
() const
返迴綫條的起始點。
另請參閱 setP1 (), x1 (), y1 (),和 p2 ().
[constexpr]
QPoint
QLine::
p2
() const
返迴綫的終點。
另請參閱 setP2 (), x2 (), y2 (),和 p1 ().
[constexpr]
int
QLine::
x1
() const
返迴綫條起始點的 X 坐標。
另請參閱 p1 ().
[constexpr]
int
QLine::
x2
() const
返迴綫終點的 X 坐標。
另請參閱 p2 ().
[constexpr]
int
QLine::
y1
() const
返迴綫條起始點的 Y 坐標。
另請參閱 p1 ().
[constexpr]
int
QLine::
y2
() const
返迴綫終點的 Y 坐標。
另請參閱 p2 ().
[constexpr]
QPoint
QLine::
center
() const
Returns the center point of this line. This is equivalent to ( p1 () + p2 ()) / 2, except it will never overflow.
[constexpr]
int
QLine::
dx
() const
Returns the horizontal component of the line's vector.
另請參閱 dy ().
[constexpr]
int
QLine::
dy
() const
Returns the vertical component of the line's vector.
另請參閱 dx ().
[constexpr]
bool
QLine::
isNull
() const
返迴
true
if the line does not have distinct start and end points; otherwise returns
false
.
Sets the starting point of this line to p1 .
Sets the end point of this line to p2 .
Sets this line to the start in x1 , y1 and end in x2 , y2 .
另請參閱 setP1 (), setP2 (), p1 (),和 p2 ().
Sets the start point of this line to p1 and the end point of this line to p2 .
另請參閱 setP1 (), setP2 (), p1 (),和 p2 ().
[constexpr noexcept, since 6.4]
QLineF
QLine::
toLineF
() const
Returns this line as a line with floating point accuracy.
該函數在 Qt 6.4 引入。
另請參閱 QLineF::toLine ().
Translates this line by the given offset .
這是重載函數。
Translates this line the distance specified by dx and dy .
[constexpr]
QLine
QLine::
translated
(const
QPoint
&
offset
) const
Returns this line translated by the given offset .
[constexpr]
QLine
QLine::
translated
(
int
dx
,
int
dy
) const
這是重載函數。
Returns this line translated the distance specified by dx and dy .
[constexpr noexcept]
bool
operator!=
(const
QLine
&
lhs
, const
QLine
&
rhs
)
返迴
true
if the line
lhs
is not the same as line
rhs
.
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.
寫入給定 line 到給定 stream 並返迴流引用。
另請參閱 序列化 Qt 數據類型 .
[constexpr noexcept]
bool
operator==
(const
QLine
&
lhs
, const
QLine
&
rhs
)
返迴
true
if the line
lhs
is the same as line
rhs
.
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.
Reads a line from the given stream 進給定 line 並返迴流引用。
另請參閱 序列化 Qt 數據類型 .