QPolygonF Class
The QPolygonF class provides a vector of points using floating point precision. More...
Header: | #include <QPolygonF> |
qmake: | QT += gui |
Inherits: | QVector |
Note: All functions in this class are reentrant.
Public Functions
QRectF | boundingRect() const |
QPolygonF | intersected(const QPolygonF &r) const |
bool | intersects(const QPolygonF &p) const |
QPolygonF | subtracted(const QPolygonF &r) const |
QPolygon | toPolygon() const |
void | translate(const QPointF &offset) |
QPolygonF | translated(const QPointF &offset) const |
QPolygonF | united(const QPolygonF &r) const |
QVariant | operator QVariant() const |
Detailed Description
A QPolygonF is a QVector<QPointF>. The easiest way to add points to a QPolygonF is to use its streaming operator, as illustrated below:
QPolygonF polygon; polygon << QPointF(10.4, 20.5) << QPointF(20.2, 30.2);
In addition to the functions provided by QVector, QPolygonF provides the boundingRect() and translate() functions for geometry operations. Use the QMatrix::map() function for more general transformations of QPolygonFs.
QPolygonF also provides the isClosed() function to determine whether a polygon's start and end points are the same, and the toPolygon() function returning an integer precision copy of this polygon.
The QPolygonF class is implicitly shared.
See also QVector, QPolygon, and QLineF.
Member Function Documentation
QRectF QPolygonF::boundingRect() const
Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty.
See also QVector::isEmpty().
QPolygonF QPolygonF::intersected(const QPolygonF &r) const
Returns a polygon which is the intersection of this polygon and r.
Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.
This function was introduced in Qt 4.3.
See also intersects().
bool QPolygonF::intersects(const QPolygonF &p) const
Returns true
if the current polygon intersects at any point the given polygon p. Also returns true
if the current polygon contains or is contained by any part of p.
Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.
This function was introduced in Qt 5.10.
See also intersected().
QPolygonF QPolygonF::subtracted(const QPolygonF &r) const
Returns a polygon which is r subtracted from this polygon.
Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.
This function was introduced in Qt 4.3.
QPolygon QPolygonF::toPolygon() const
Creates and 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.
See also translated().
QPolygonF QPolygonF::translated(const QPointF &offset) const
Returns a copy of the polygon that is translated by the given offset.
This function was introduced in Qt 4.6.
See also translate().
QPolygonF QPolygonF::united(const QPolygonF &r) const
Returns a polygon which is the union of this polygon and r.
Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.
This function was introduced in Qt 4.3.
See also intersected() and subtracted().
QVariant QPolygonF::operator QVariant() const
Returns the polygon as a QVariant.