Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

QPolygonF Class Reference
[QtGui module]

The QPolygonF class provides a vector of floating point points. More...

#include <QPolygonF>

Inherits QVector<QPointF>.

Note: All the functions in this class are reentrant.

Public Functions

Related Non-Members

Additional Inherited Members


Detailed Description

The QPolygonF class provides a vector of floating point points.

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

The easiest way to add points to a QPolygonF is to use QVector's streaming operators, as illustrated below:

            QPolygonF polygon;
            polygon << QPointF(10, 20) << QPointF(20, 30);

All other forms of manipulating a vector are available too.

For geometry operations use boundingRect() and translate(). There is also the QMatrix::map() function for more general transformations of QPolygonFs.

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

See also QPainter, QMatrix, QVector, and QPolygon.


Member Function Documentation

QPolygonF::QPolygonF ()

Constructs a polygon with no points.

See also QVector::isEmpty().

QPolygonF::QPolygonF ( int size )

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

See also QVector::isEmpty().

QPolygonF::QPolygonF ( const QPolygonF & other )

Copy constructor. Constructs a copy of the other polygon.

QPolygonF::QPolygonF ( const QVector<QPointF> & vector )

Constructs a polygon from the given vector of points.

QPolygonF::QPolygonF ( 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.

See also QPolygon::QPolygon() and isClosed().

QPolygonF::QPolygonF ( const QPolygon & a )

Constructs a float based polygon from the int based polygon specified by a.

See also toPolygon().

QPolygonF::~QPolygonF ()

Destroys the point array.

QRectF QPolygonF::boundingRect () const

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

bool QPolygonF::isClosed () const

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

A polygon is said to be closed if its start point and end point are equal.

See also QVector::first() and QVector::last().

QPolygon QPolygonF::toPolygon () const

Returns a QPolygon by converting each QPointF to a QPoint.

See also QPointF::toPoint().

void QPolygonF::translate ( const QPointF & offset )

Translate all points in the polygon by the given offset.

void QPolygonF::translate ( qreal dx, qreal 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 QPolygonF & 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, QPolygonF & 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.


Copyright © 2005 Trolltech Trademarks
Qt 4.1.0
Hosted by uCoz