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

# QLineF Class Reference

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

    #include <QLineF>

- List of all members, including inherited members

### Public Types

- enum IntersectType { NoIntersection, UnboundedIntersection, BoundedIntersection }

### Public Functions

- QLineF ()
- QLineF ( const QPointF & pt1, const QPointF & pt2 )
- QLineF ( float x1, float y1, float x2, float y2 )
- float angle ( const QLineF & line ) const
- QPointF end () const
- float endX () const
- float endY () const
- IntersectType intersect ( const QLineF & other, QPointF * intersectionPoint ) const
- bool isNull () const
- float length () const
- void moveBy ( const QLineF & line )
- QLineF normalVector () const
- QPointF pointAt ( float t ) const
- void setLength ( float length )
- QPointF start () const
- float startX () const
- float startY () const
- QLineF unitVector () const
- float vx () const
- float vy () const
- void operator+= ( const QPointF & other )

## Detailed Description

The QLineF class provides a two-dimensional vector that uses floating point coordinates for accuracy.

A QLineF 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 QLineF represents a valid line or a null line.

The positions of the line's end points can be found with the startX(), startY(), endX(), and endY() functions. The horizontal and vertical components of the line are returned by the vx() and vy() functions.

Convenience functions are provided for finding the lines's length(), the unitVector() along the line, whether two lines intersect(), and the angle() between two lines. The line's length can be changed using setLength().

Vector addition of two lines is supported through the use of the += operator.

The line can be translated along the length of another line with the moveBy() function, and can be traversed using a parameter with the pointAt() function.

See also QPointF, QSizeF, and QRectF.

## Member Type Documentation

### enum QLineF::IntersectType

`QLineF::NoIntersection` | Indicates that the lines do not intersect; i.e. they are parallel.
`QLineF::UnboundedIntersection` | The two lines intersect, but not within the range defined by their lengths. This will be the case if the lines are not parallel.
`QLineF::BoundedIntersection` | The two lines intersect with each other within the start and end points of each line.

## Member Function Documentation

### QLineF::QLineF ()

Constructs a null line.

### QLineF::QLineF ( const QPointF & pt1, const QPointF & pt2 )

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

### QLineF::QLineF ( float x1, float y1, float x2, float y2 )

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

### float QLineF::angle ( const QLineF & line ) const

Returns the smallest angle between the given line and this line, not taking into account whether the lines intersect or not. The angle is specified in degrees.

### QPointF QLineF::end () const

Returns the line's end point.

### float QLineF::endX () const

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

### float QLineF::endY () const

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

### IntersectType QLineF::intersect ( const QLineF & other, QPointF * intersectionPoint ) const

Returns a value indicating whether or not this line intersects the other line. By passing a valid object as intersectionPoint, it is possible to get the actual intersection point. The intersection point is undefined if the lines are parallel.

### bool QLineF::isNull () const

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

### float QLineF::length () const

Returns the length of the line.

See also setLength().

### void QLineF::moveBy ( const QLineF & line )

Translates this line by the vector specified by the line given.

### QLineF QLineF::normalVector () const

Returns a line that is perpendicular to this line with the same starting point and length.

### QPointF QLineF::pointAt ( float t ) const

Returns the point at the parameterized position t, where the start and end point are defined to be at positions t=0 and t=1.

### void QLineF::setLength ( float length )

Sets the length of the line.

See also length().

### QPointF QLineF::start () const

Returns the line's start point.

### float QLineF::startX () const

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

### float QLineF::startY () const

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

### QLineF QLineF::unitVector () const

Returns a normalized version of this line, starting at the same point as this line. A normalized line is a line of unit length (length() is equal to 1.0).

### float QLineF::vx () const

Returns the horizontal component of the line's vector.

### float QLineF::vy () const

Returns the vertical component of the line's vector.

### void QLineF::operator+= ( const QPointF & other )

Performs a vector addition of this line with the other line given.