6.0.0-rc4Source

QLineF Class

The QLineF class provides a two-dimensional vector using floating point precision. More…

Header#include <QLineF>
CMaketarget_link_libraries(app PRIVATE Nt::Core)
ModuleNt Core C++ Classes

List of all members, including inherited members

Public Types

Public Functions

QLineF()
QLineF(const QPointF &p1, const QPointF &p2)
QLineF(double x1, double y1, double x2, double y2)
QLineF(const QLine &l)
boolisNull() const
QPointFp1() const
QPointFp2() const
doublex1() const
doubley1() const
doublex2() const
doubley2() const
doubledx() const
doubledy() const
QPointFcenter() const
doublelength() const
voidsetLength(double len)
doubleangle() const
voidsetAngle(double angle)
doubleangleTo(const QLineF &o) const
QLineFunitVector() const
QLineFnormalVector() const
QPointFpointAt(double t) const
QLinetoLine() const
IntersectionTypeintersects(const QLineF &l, QPointF *point = nullptr) const
voidsetP1(const QPointF &p)
voidsetP2(const QPointF &p)
voidsetPoints(const QPointF &p, const QPointF &q)
voidsetLine(double x1, double y1, double x2, double y2)
voidtranslate(const QPointF &p)
voidtranslate(double dx, double dy)
QLineFtranslated(const QPointF &p) const
QLineFtranslated(double dx, double dy) const

Static Public Members

QLineFfromPolar(double length, double angle)

Detailed Description

A QLineF describes a finite line (or line segment) by its two end points, stored as QPointF values. Angles are measured in degrees, counter-clockwise from the positive x axis; since the y axis points down, a positive angle turns the line upwards on screen.

See also QLine and QPointF.

Differences from Qt

Coordinates are always double, which is what qreal is in Nt.

Member Type Documentation

enum QLineF::IntersectionType

Describes the type of intersection found by intersects().

ConstantDescription
QLineF::NoIntersectionThe lines do not intersect, because they are parallel.
QLineF::BoundedIntersectionThe lines intersect at a point that lies within both line segments.
QLineF::UnboundedIntersectionThe lines would intersect if extended indefinitely, but the intersection point lies outside at least one of the segments.

See also intersects().

Member Function Documentation

[constexpr] QLineF::QLineF()

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

See also isNull().

[constexpr] QLineF::QLineF(const QPointF &p1, const QPointF &p2)

Constructs a line object that represents the line between p1 and p2.

[constexpr] QLineF::QLineF(double x1, double y1, double x2, double y2)

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

[constexpr] QLineF::QLineF(const QLine &l)

Construct a QLineF object from the given integer-based line l.

See also toLine().

double QLineF::angle() const

Returns the angle of the line in degrees, measured counter-clockwise from the positive x axis, in the range [0, 360).

See also setAngle() and angleTo().

double QLineF::angleTo(const QLineF &o) const

Returns the angle in degrees, in the range [0, 360), by which this line must be rotated counter-clockwise to have the direction of the o line. Returns 0 if either line is null.

See also angle().

[constexpr] QPointF QLineF::center() const

Returns the center point of this line, the midpoint between the end points.

[constexpr] double QLineF::dx() const

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

See also dy().

[constexpr] double QLineF::dy() const

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

See also dx().

[static] QLineF QLineF::fromPolar(double length, double angle)

Returns a QLineF with the given length and angle, starting at the origin.

The angle is in degrees, measured counter-clockwise from the positive x axis.

See also setLength() and setAngle().

IntersectionType QLineF::intersects(const QLineF &l, QPointF *point = nullptr) const

Returns a value indicating whether this line and the line l intersect, and if so how.

If the lines are not parallel and point is not nullptr, it is set to the intersection point, even when the intersection is unbounded. If the lines are parallel, point is left unchanged.

See also IntersectionType.

bool QLineF::isNull() const

Returns true if the start point equals the end point; otherwise returns false.

double QLineF::length() const

Returns the length of the line.

See also setLength().

[constexpr] QLineF QLineF::normalVector() const

Returns a line that is perpendicular to this line, starts at the same point and has the same length.

See also unitVector().

[constexpr] QPointF QLineF::p1() const

Returns the line's start point.

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

[constexpr] QPointF QLineF::p2() const

Returns the line's end point.

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

[constexpr] QPointF QLineF::pointAt(double t) const

Returns the point at the parameterized position t, where 0.0 is the start point, 1.0 is the end point, and other values lie on the extension of the line.

void QLineF::setAngle(double angle)

Sets the angle of the line to the given angle in degrees, measured counter-clockwise from the positive x axis. The start point and the length of the line are kept.

See also angle() and length().

void QLineF::setLength(double len)

Sets the length of the line to the given len, keeping the start point and the direction. Does nothing if the line has zero length.

See also length() and unitVector().

[constexpr] void QLineF::setLine(double x1, double y1, double x2, double y2)

Sets this line to the start point (x1, y1) and end point (x2, y2).

See also setP1(), setP2() and setPoints().

[constexpr] void QLineF::setP1(const QPointF &p)

Sets the start point of this line to p.

See also setP2() and p1().

[constexpr] void QLineF::setP2(const QPointF &p)

Sets the end point of this line to p.

See also setP1() and p2().

[constexpr] void QLineF::setPoints(const QPointF &p, const QPointF &q)

Sets the start point of this line to p and the end point to q.

See also setP1(), setP2() and setLine().

QLine QLineF::toLine() const

Returns an integer-based copy of this line, with the end points rounded to the nearest integer.

See also QLineF(const QLine &).

[constexpr] void QLineF::translate(const QPointF &p)

Translates this line by the given offset p.

See also translated().

[constexpr] void QLineF::translate(double dx, double dy)

This is an overloaded function.

Translates this line the distance specified by dx and dy.

[constexpr] QLineF QLineF::translated(const QPointF &p) const

Returns this line translated by the given offset p.

See also translate().

[constexpr] QLineF QLineF::translated(double dx, double dy) const

This is an overloaded function.

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

QLineF QLineF::unitVector() const

Returns the unit vector for this line, that is, a line starting at the same point with a length of 1.0 and the same direction. If this line has zero length, it is returned unchanged.

See also normalVector() and setLength().

[constexpr] double QLineF::x1() const

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

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

[constexpr] double QLineF::x2() const

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

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

[constexpr] double QLineF::y1() const

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

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

[constexpr] double QLineF::y2() const

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

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