QLine Class
The QLine class provides a two-dimensional vector using integer precision. More…
| Header | #include <QLine> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
List of all members, including inherited members
Public Functions
| QLine() | |
| QLine(const QPoint &p1, const QPoint &p2) | |
| QLine(int x1, int y1, int x2, int y2) | |
| bool | isNull() const |
| QPoint | p1() const |
| QPoint | p2() const |
| int | x1() const |
| int | y1() const |
| int | x2() const |
| int | y2() const |
| int | dx() const |
| int | dy() const |
| QPoint | center() const |
| void | setP1(const QPoint &p) |
| void | setP2(const QPoint &p) |
| void | setPoints(const QPoint &p, const QPoint &q) |
| void | setLine(int x1, int y1, int x2, int y2) |
| void | translate(const QPoint &p) |
| void | translate(int dx, int dy) |
| QLine | translated(const QPoint &p) const |
| QLine | translated(int dx, int dy) const |
| QLineF | toLineF() const |
Detailed Description
A QLine describes a finite line (or line segment) by its two end points, stored as QPoint values. Use QLineF for floating-point coordinates and for operations such as intersection and angles.
Differences from Qt
None.
Member Function Documentation
QLine::QLine()
Constructs a null line, with both end points at (0, 0).
See also isNull().
QLine::QLine(const QPoint &p1, const QPoint &p2)
Constructs a line object that represents the line between p1 and p2.
QLine::QLine(int x1, int y1, int x2, int y2)
Constructs a line object that represents the line between (x1, y1) and (x2, y2).
QPoint QLine::center() const
Returns the center point of this line, the average of the two end points with each coordinate truncated to an integer.
int QLine::dx() const
Returns the horizontal component of the line's vector, that is, x2() - x1().
See also dy().
int QLine::dy() const
Returns the vertical component of the line's vector, that is, y2() - y1().
See also dx().
bool QLine::isNull() const
Returns true if the line is not set up with valid start and end points, that is, if the start point equals the end point; otherwise returns false.
QPoint QLine::p1() const
Returns the line's start point.
See also setP1(), x1(), y1() and p2().
QPoint QLine::p2() const
Returns the line's end point.
See also setP2(), x2(), y2() and p1().
void QLine::setLine(int x1, int y1, int x2, int y2)
Sets this line to the start point (x1, y1) and end point (x2, y2).
See also setP1(), setP2() and setPoints().
void QLine::setP1(const QPoint &p)
Sets the start point of this line to p.
void QLine::setP2(const QPoint &p)
Sets the end point of this line to p.
void QLine::setPoints(const QPoint &p, const QPoint &q)
Sets the start point of this line to p and the end point to q.
See also setP1(), setP2() and setLine().
QLineF QLine::toLineF() const
Returns this line as a line with floating point accuracy.
This function was introduced in 6.4.
See also QLineF::toLine().
void QLine::translate(const QPoint &p)
Translates this line by the given offset p.
See also translated().
void QLine::translate(int dx, int dy)
This is an overloaded function.
Translates this line the distance specified by dx and dy.
QLine QLine::translated(const QPoint &p) const
Returns this line translated by the given offset p.
See also translate().
QLine QLine::translated(int dx, int dy) const
This is an overloaded function.
Returns this line translated the distance specified by dx and dy.
int QLine::x1() const
Returns the x coordinate of the line's start point.
int QLine::x2() const
Returns the x coordinate of the line's end point.
int QLine::y1() const
Returns the y coordinate of the line's start point.
int QLine::y2() const
Returns the y coordinate of the line's end point.