|  | Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# QLine Class Reference
[QtCore module]

The QLine class provides a two-dimensional vector that uses integer point accuracy for coordinates. More...

    #include <QLine>

- List of all members, including inherited members

### 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
- int dx () const
- int dy () const
- bool isNull () const
- void translate ( const QPoint & point )
- void translate ( int dx, int dy )
- bool operator!= ( const QLine & other ) const
- bool operator== ( const QLine & other ) const

### Related Non-Members

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

## Detailed Description

The QLine class provides a two-dimensional vector that uses integer point accuracy for coordinates.

A QLine describes a finite length line (or line segment) on a two-dimensional surface. The start and end points of the line are specified using integer point coordinates.

Use isNull() to determine whether the QLine represents a valid line or a null line.

[Missing image qline-point.png] | [Missing image qline-coordinates.png]

The positions of the line's end points can be found with the p1(), x1(), y1(), p2(), x2(), and y2() functions. The horizontal and vertical components of the line are returned by the dx() and dy() functions.

The line can be translated along the length of another line with the translate() function.

See also QPoint, QSize, QRect, and QLineF.

## Member Function Documentation

### QLine::QLine ()

Constructs a null line.

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

Constructs a line object that represents the line between pt1 and pt2.

### 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::p1 () const

Returns the line's start point.

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

### QPoint QLine::p2 () const

Returns the line's end point.

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

### int QLine::x1 () const

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

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

### int QLine::x2 () const

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

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

### int QLine::y1 () const

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

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

### int QLine::y2 () const

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

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

### int QLine::dx () const

Returns the horizontal component of the line's vector.

See also dy().

### int QLine::dy () const

Returns the vertical component of the line's vector.

See also dx().

### bool QLine::isNull () const

Returns true if the line is not set up with valid start and end point; otherwise returns false.

### void QLine::translate ( const QPoint & point )

Translates this line with the point given.

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Translates this line the distance dx and dy.

### bool QLine::operator!= ( const QLine & other ) const

Returns true if other is not the same as this line.

A line is different from another line if any of their points are different or their order is different.

### bool QLine::operator== ( const QLine & other ) const

Returns true if other is the same line as this line.

A line is identical to another line if the points are the same and their order is the same.

## Related Non-Members

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

See also Format of the QDataStream operators.

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

See also Format of the QDataStream operators.