|  | Home · All Classes · Modules

# QLine Class Reference
[QtCore module]

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

### Methods

- __init__ (self)
- __init__ (self, QPoint pt1_, QPoint pt2_)
- __init__ (self, int x1pos, int y1pos, int x2pos, int y2pos)
- __init__ (self, QLine other)
- int dx (self)
- int dy (self)
- bool isNull (self)
- QPoint p1 (self)
- QPoint p2 (self)
- setLine (self, int aX1, int aY1, int aX2, int aY2)
- setP1 (self, QPoint aP1)
- setP2 (self, QPoint aP2)
- setPoints (self, QPoint aP1, QPoint aP2)
- translate (self, QPoint point)
- translate (self, int adx, int ady)
- QLine translated (self, QPoint p)
- QLine translated (self, int adx, int ady)
- int x1 (self)
- int x2 (self)
- int y1 (self)
- int y2 (self)

### Special Methods

- QLine __mul__ (self, QMatrix m)
- QLine __mul__ (self, QTransform m)
- int __bool__ (self)
- bool __eq__ (self, QLine d)
- bool __ne__ (self, QLine d)
- object __repr__ (self)

## Detailed Description

This class can be pickled.

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.

## Method Documentation

### QLine.__init__ (self)

Constructs a null line.

### QLine.__init__ (self, QPoint pt1_, QPoint pt2_)

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

### QLine.__init__ (self, int x1pos, int y1pos, int x2pos, int y2pos)

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

### QLine.__init__ (self, QLine other)

### int QLine.dx (self)

Returns the horizontal component of the line's vector.

See also dy().

### int QLine.dy (self)

Returns the vertical component of the line's vector.

See also dx().

### bool QLine.isNull (self)

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

### QPoint QLine.p1 (self)

Returns the line's start point.

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

### QPoint QLine.p2 (self)

Returns the line's end point.

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

### QLine.setLine (self, int aX1, int aY1, int aX2, int aY2)

Sets this line to the start in x1, y1 and end in x2, y2.

This function was introduced in Qt 4.4.

See also setP1(), setP2(), p1(), and p2().

### QLine.setP1 (self, QPoint aP1)

Sets the starting point of this line to p1.

This function was introduced in Qt 4.4.

See also setP2() and p1().

### QLine.setP2 (self, QPoint aP2)

Sets the end point of this line to p2.

This function was introduced in Qt 4.4.

See also setP1() and p2().

### QLine.setPoints (self, QPoint aP1, QPoint aP2)

Sets the start point of this line to p1 and the end point of this line to p2.

This function was introduced in Qt 4.4.

See also setP1(), setP2(), p1(), and p2().

### QLine.translate (self, QPoint point)

Translates this line by the given offset.

### QLine.translate (self, int adx, int ady)

This is an overloaded function.

Translates this line the distance specified by dx and dy.

### QLine QLine.translated (self, QPoint p)

Returns this line translated by the given offset.

This function was introduced in Qt 4.4.

### QLine QLine.translated (self, int adx, int ady)

This is an overloaded function.

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

This function was introduced in Qt 4.4.

### int QLine.x1 (self)

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

See also p1().

### int QLine.x2 (self)

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

See also p2().

### int QLine.y1 (self)

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

See also p1().

### int QLine.y2 (self)

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

See also p2().

### QLine __mul__ (self, QMatrix m)

This method is only available if the QtGui module is imported.

### QLine __mul__ (self, QTransform m)

This method is only available if the QtGui module is imported.

### int QLine.__bool__ (self)

### bool QLine.__eq__ (self, QLine d)

### bool QLine.__ne__ (self, QLine d)

### object QLine.__repr__ (self)