6.0.0-rc4Source

QLine Class

The QLine class provides a two-dimensional vector using integer precision. More…

Header#include <QLine>
CMaketarget_link_libraries(app PRIVATE Nt::Core)
ModuleNt 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)
boolisNull() const
QPointp1() const
QPointp2() const
intx1() const
inty1() const
intx2() const
inty2() const
intdx() const
intdy() const
QPointcenter() const
voidsetP1(const QPoint &p)
voidsetP2(const QPoint &p)
voidsetPoints(const QPoint &p, const QPoint &q)
voidsetLine(int x1, int y1, int x2, int y2)
voidtranslate(const QPoint &p)
voidtranslate(int dx, int dy)
QLinetranslated(const QPoint &p) const
QLinetranslated(int dx, int dy) const
QLineFtoLineF() 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.

See also QLineF and QPoint.

Differences from Qt

None.

Member Function Documentation

[constexpr] QLine::QLine()

Constructs a null line, with both end points at (0, 0).

See also isNull().

[constexpr] QLine::QLine(const QPoint &p1, const QPoint &p2)

Constructs a line object that represents the line between 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) and (x2, y2).

[constexpr] 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.

[constexpr] int QLine::dx() const

Returns the horizontal component of the line's vector, that is, x2() - x1().

See also dy().

[constexpr] int QLine::dy() const

Returns the vertical component of the line's vector, that is, y2() - y1().

See also dx().

[constexpr] 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.

[constexpr] QPoint QLine::p1() const

Returns the line's start point.

See also setP1(), x1(), y1() and p2().

[constexpr] QPoint QLine::p2() const

Returns the line's end point.

See also setP2(), x2(), y2() and p1().

[constexpr] 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().

[constexpr] void QLine::setP1(const QPoint &p)

Sets the start point of this line to p.

See also setP2() and p1().

[constexpr] void QLine::setP2(const QPoint &p)

Sets the end point of this line to p.

See also setP1() and p2().

[constexpr] 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().

[constexpr] 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().

[constexpr] void QLine::translate(const QPoint &p)

Translates this line by the given offset p.

See also translated().

[constexpr] void QLine::translate(int dx, int dy)

This is an overloaded function.

Translates this line the distance specified by dx and dy.

[constexpr] QLine QLine::translated(const QPoint &p) const

Returns this line translated by the given offset p.

See also translate().

[constexpr] QLine QLine::translated(int dx, int dy) const

This is an overloaded function.

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

[constexpr] int QLine::x1() const

Returns the x coordinate of the line's start point.

See also p1(), y1() and x2().

[constexpr] int QLine::x2() const

Returns the x coordinate of the line's end point.

See also p2(), y2() and x1().

[constexpr] int QLine::y1() const

Returns the y coordinate of the line's start point.

See also p1(), x1() and y2().

[constexpr] int QLine::y2() const

Returns the y coordinate of the line's end point.

See also p2(), x2() and y1().