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

# QPolygon Class Reference

The QPolygon class provides a vector of points. More...

    #include <QPolygon>

Inherits QVector<QPointF>.

Note: All the functions in this class are reentrant.

- List of all members, including inherited members

### Public Functions

- QPolygon ()
- QPolygon ( int size )
- QPolygon ( const QPolygon & other )
- QPolygon ( const QVector<QPointF> & vector )
- QPolygon ( const QRectF & rect )
- ~QPolygon ()
- QRectF boundingRect () const
- bool isClosed () const
- QPointArray toPointArray () const
- void translate ( const QPointF & offset )
- void translate ( float dx, float dy )

- 59 public functions inherited from QVector

### Static Public Members

- QPolygon fromPointArray ( const QPointArray & array )

### Related Non-Members

- QDataStream & operator<< ( QDataStream & s, const QPolygon & a )
- QDataStream & operator>> ( QDataStream & s, QPolygon & a )

## Detailed Description

The QPolygon class provides a vector of points.

A QPolygon is a QVector<QPoint>. It is implicitly shared. In addition to the functions provided by QVector, QPolygon provides some point-specific functions.

For convenient reading and writing of the point data use setPoints(), putPoints(), point(), and setPoint().

For geometry operations use boundingRect() and translate(). There is also the QMatrix::map() function for more general transformations of QPolygons. You can also create arcs and ellipses with makeArc() and makeEllipse().

Among others, QPolygon is used by QPainter::drawLineSegments(), QPainter::drawPolyline(), QPainter::drawPolygon() and QPainter::drawCubicBezier().

See also QPainter, QMatrix, and QVector.

## Member Function Documentation

### QPolygon::QPolygon ()

Constructs a polygon with no points.

See also QVector::isEmpty().

### QPolygon::QPolygon ( int size )

Constructs a polygon with size points. Makes a polygon with no points if size == 0.

See also QVector::isEmpty().

### QPolygon::QPolygon ( const QPolygon & other )

Copy constructor. Constructs a copy of the other polygon.

### QPolygon::QPolygon ( const QVector<QPointF> & vector )

Constructs a polygon from the given vector of points.

### QPolygon::QPolygon ( const QRectF & rect )

Constructs a closed polygon from the rectangle specified by rect.

The point array just contains the four vertices of the rectangle in clockwise order starting and ending with the top-left vertex.

### QPolygon::~QPolygon ()

Destroys the point array.

### QRectF QPolygon::boundingRect () const

Returns the bounding rectangle of the polygon, or QRect(0,0,0,0) if the array is empty.

### QPolygon QPolygon::fromPointArray ( const QPointArray & array ) `[static]`

Constructs a polygon from the given point array. The polygon will not be closed.

See also toPointArray().

### bool QPolygon::isClosed () const

Returns true if the polygon is closed; otherwise returns false.

### QPointArray QPolygon::toPointArray () const

Returns the polygons vertices as a list of points.

See also fromPointArray().

### void QPolygon::translate ( const QPointF & offset )

Translates all points in the polygon by the given offset.

### void QPolygon::translate ( float dx, float dy )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Translates all points in the polygon by (dx, dy).

## Related Non-Members

### QDataStream & operator<< ( QDataStream & s, const QPolygon & a )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Writes the point array, a to the stream s and returns a reference to the stream.

See also Format of the QDataStream operators.

### QDataStream & operator>> ( QDataStream & s, QPolygon & a )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Reads a point array, a from the stream s and returns a reference to the stream.

See also Format of the QDataStream operators.