|  | Home · All Classes · Modules

# QGraphicsLineItem Class Reference
[QtGui module]

The QGraphicsLineItem class provides a line item that you can add to a QGraphicsScene. More...

Inherits QGraphicsItem.

### Methods

- __init__ (self, QGraphicsItem parent = None, QGraphicsScene scene = None)
- __init__ (self, QLineF, QGraphicsItem parent = None, QGraphicsScene scene = None)
- __init__ (self, float, float, float, float, QGraphicsItem parent = None, QGraphicsScene scene = None)
- QRectF boundingRect (self)
- bool contains (self, QPointF)
- bool isObscuredBy (self, QGraphicsItem)
- QLineF line (self)
- QPainterPath opaqueArea (self)
- paint (self, QPainter, QStyleOptionGraphicsItem, QWidget widget = None)
- QPen pen (self)
- setLine (self, QLineF)
- setLine (self, float, float, float, float)
- setPen (self, QPen)
- QPainterPath shape (self)
- int type (self)

## Detailed Description

The QGraphicsLineItem class provides a line item that you can add to a QGraphicsScene.

To set the item's line, pass a QLineF to QGraphicsLineItem's constructor, or call the setLine() function. The line() function returns the current line. By default the line is black with a width of 0, but you can change this by calling setPen().

QGraphicsLineItem uses the line and the pen width to provide a reasonable implementation of boundingRect(), shape(), and contains(). The paint() function draws the line using the item's associated pen.

See also QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem, and The Graphics View Framework.

## Method Documentation

### QGraphicsLineItem.__init__ (self, QGraphicsItem parent = None, QGraphicsScene scene = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

The scene argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a QGraphicsLineItem. parent is passed to QGraphicsItem's constructor.

See also QGraphicsScene.addItem().

### QGraphicsLineItem.__init__ (self, QLineF, QGraphicsItem parent = None, QGraphicsScene scene = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

The scene argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a QGraphicsLineItem, using line as the default line. parent is passed to QGraphicsItem's constructor.

See also QGraphicsScene.addItem().

### QGraphicsLineItem.__init__ (self, float, float, float, float, QGraphicsItem parent = None, QGraphicsScene scene = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

The scene argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a QGraphicsLineItem, using the line between (x1, y1) and (x2, y2) as the default line. parent is passed to QGraphicsItem's constructor.

See also QGraphicsScene.addItem().

### QRectF QGraphicsLineItem.boundingRect (self)

Reimplemented from QGraphicsItem.boundingRect().

### bool QGraphicsLineItem.contains (self, QPointF)

Reimplemented from QGraphicsItem.contains().

### bool QGraphicsLineItem.isObscuredBy (self, QGraphicsItem)

Reimplemented from QGraphicsItem.isObscuredBy().

### QLineF QGraphicsLineItem.line (self)

Returns the item's line, or a null line if no line has been set.

See also setLine().

### QPainterPath QGraphicsLineItem.opaqueArea (self)

Reimplemented from QGraphicsItem.opaqueArea().

### QGraphicsLineItem.paint (self, QPainter, QStyleOptionGraphicsItem, QWidget widget = None)

Reimplemented from QGraphicsItem.paint().

### QPen QGraphicsLineItem.pen (self)

Returns the item's pen, or a black solid 0-width pen if no pen has been set.

See also setPen().

### QGraphicsLineItem.setLine (self, QLineF)

Sets the item's line to be the given line.

See also line().

### QGraphicsLineItem.setLine (self, float, float, float, float)

This is an overloaded function.

Sets the item's line to be the line between (x1, y1) and (x2, y2).

This is the same as calling `setLine(QLineF(x1, y1, x2, y2))`.

### QGraphicsLineItem.setPen (self, QPen)

Sets the item's pen to pen. If no pen is set, the line will be painted using a black solid 0-width pen.

See also pen().

### QPainterPath QGraphicsLineItem.shape (self)

Reimplemented from QGraphicsItem.shape().

### int QGraphicsLineItem.type (self)

Reimplemented from QGraphicsItem.type().