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

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

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

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

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

### QPainterPath QGraphicsPolygonItem.opaqueArea (self)

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

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

### int QGraphicsPolygonItem.type (self)