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

# QLine Class Reference

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

    #include <QLine>

Part of the QtCore module.

- 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 )
- int dx () const
- int dy () const
- bool isNull () const
- QPoint p1 () const
- QPoint p2 () const
- void translate ( const QPoint & point )
- void translate ( int dx, int dy )
- int x1 () const
- int x2 () const
- int y1 () const
- int y2 () const
- bool operator!= ( const QLine & d ) 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 coordinates for accuracy.

A QLine describes a finite length line on a two-dimensional surface. The start and end points of the line are specified using floating point coordinates for accuracy.

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

The positions of the line's end points can be found with the x1(), y1(), 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).

### int QLine::dx () const

Returns the horizontal component of the line's vector.

### int QLine::dy () const

Returns the vertical component of the line's vector.

### bool QLine::isNull () const

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

### QPoint QLine::p1 () const

Returns the line's start point.

### QPoint QLine::p2 () const

Returns the line's end point.

### 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.

### 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.

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

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

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

A line is identical if the two 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.