|  | Home · All Classes · Modules

# QGraphicsPolygonItem Class Reference
[QtGui module]

The QGraphicsPolygonItem class provides a polygon item that you can add to a QGraphicsScene. More...

Inherits QAbstractGraphicsShapeItem.

### Methods

- __init__ (self, QGraphicsItem parent = None, QGraphicsScene scene = None)
- __init__ (self, QPolygonF polygon, QGraphicsItem parent = None, QGraphicsScene scene = None)
- QRectF boundingRect (self)
- bool contains (self, QPointF point)
- Qt.FillRule fillRule (self)
- bool isObscuredBy (self, QGraphicsItem item)
- QPainterPath opaqueArea (self)
- paint (self, QPainter painter, QStyleOptionGraphicsItem option, QWidget widget = None)
- QPolygonF polygon (self)
- setFillRule (self, Qt.FillRule rule)
- setPolygon (self, QPolygonF polygon)
- QPainterPath shape (self)
- int type (self)

## Detailed Description

The QGraphicsPolygonItem class provides a polygon item that you can add to a QGraphicsScene.

To set the item's polygon, pass a QPolygonF to QGraphicsPolygonItem's constructor, or call the setPolygon() function. The polygon() function returns the current polygon.

QGraphicsPolygonItem uses the polygon and the pen width to provide a reasonable implementation of boundingRect(), shape(), and contains(). The paint() function draws the polygon using the item's associated pen and brush, which you can set by calling the setPen() and setBrush() functions.

## Method Documentation

### QGraphicsPolygonItem.__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 QGraphicsPolygonItem. parent is passed to QAbstractGraphicsShapeItem's constructor.

See also QGraphicsScene.addItem().

### QGraphicsPolygonItem.__init__ (self, QPolygonF polygon, 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 QGraphicsPolygonItem with polygon as the default polygon. parent is passed to QAbstractGraphicsShapeItem's constructor.

See also QGraphicsScene.addItem().

### QRectF QGraphicsPolygonItem.boundingRect (self)

Reimplemented from QGraphicsItem.boundingRect().

### bool QGraphicsPolygonItem.contains (self, QPointF point)

Reimplemented from QGraphicsItem.contains().

### Qt.FillRule QGraphicsPolygonItem.fillRule (self)

Returns the fill rule of the polygon. The default fill rule is Qt.OddEvenFill.

See also setFillRule(), QPainterPath.fillRule(), and QPainter.drawPolygon().

### bool QGraphicsPolygonItem.isObscuredBy (self, QGraphicsItem item)

Reimplemented from QGraphicsItem.isObscuredBy().

### QPainterPath QGraphicsPolygonItem.opaqueArea (self)

Reimplemented from QGraphicsItem.opaqueArea().

### QGraphicsPolygonItem.paint (self, QPainter painter, QStyleOptionGraphicsItem option, QWidget widget = None)

Reimplemented from QGraphicsItem.paint().

### QPolygonF QGraphicsPolygonItem.polygon (self)

Returns the item's polygon, or an empty polygon if no polygon has been set.

See also setPolygon().

### QGraphicsPolygonItem.setFillRule (self, Qt.FillRule rule)

Sets the fill rule of the polygon to rule. The default fill rule is Qt.OddEvenFill.

See also fillRule(), QPainterPath.fillRule(), and QPainter.drawPolygon().

### QGraphicsPolygonItem.setPolygon (self, QPolygonF polygon)

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

See also polygon().

### QPainterPath QGraphicsPolygonItem.shape (self)

Reimplemented from QGraphicsItem.shape().

### int QGraphicsPolygonItem.type (self)

Reimplemented from QGraphicsItem.type().