QLine Class

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

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

Public Functions

QLine()
QLine(const QPoint &pt1, const QPoint &pt2)
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)
void translate(const QPoint &p)
void translate(int dx, int dy)
QLine translated(const QPoint &p) const
QLine translated(int dx, int dy) const
bool operator!=(const QLine &d) const
bool operator==(const QLine &d) const
QDataStream &operator<<(QDataStream &stream, const QLine &line)
QDataStream &operator>>(QDataStream &stream, QLine &line)

Detailed Description

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

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(), and y2() functions. The dx() and 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() function.

See also QLineF, QPolygon, and QRect.

Member Type Documentation

Property Documentation

Member Function Documentation

QLine::QLine()

Default constructs an instance of QLine.

QLine::QLine(const QPoint &pt1, const QPoint &pt2)

Default constructs an instance of QLine.

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

Default constructs an instance of QLine.

QPoint QLine::p1() const

See also setP1().

QPoint QLine::p2() const

See also setP2().

int QLine::x1() const

int QLine::x2() const

int QLine::y1() const

int QLine::y2() const

QPoint QLine::center() const

int QLine::dx() const

int QLine::dy() const

bool QLine::isNull() const

void QLine::setP1(const QPoint &p1)

See also p1().

void QLine::setP2(const QPoint &p2)

See also p2().

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

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

void QLine::translate(const QPoint &p)

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

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

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

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

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

Member Variable Documentation

Related Non-Members

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

Writes the given line to the given stream and returns a reference to the stream.

See also Serializing Qt Data Types.

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

Reads a line from the given stream into the given line and returns a reference to the stream.

See also Serializing Qt Data Types.

Macro Documentation