The QPolygonF class provides a list of points using floating point precision. More...
Header: | #include <QPolygonF> |
CMake: | find_package(Qt6 COMPONENTS Gui REQUIRED) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
Inherits: | QList |
Note: All functions in this class are reentrant.
QPolygonF(const QPolygon &polygon) | |
QPolygonF(const QRectF &rectangle) | |
QPolygonF(const QList<QPointF> &points) | |
QPolygonF() | |
QRectF | boundingRect() const |
bool | containsPoint(const QPointF &point, Qt::FillRule fillRule) const |
QPolygonF | intersected(const QPolygonF &r) const |
bool | intersects(const QPolygonF &p) const |
bool | isClosed() const |
QPolygonF | subtracted(const QPolygonF &r) const |
void | swap(QPolygonF &other) |
QPolygon | toPolygon() const |
void | translate(const QPointF &offset) |
void | translate(qreal dx, qreal dy) |
QPolygonF | translated(const QPointF &offset) const |
QPolygonF | translated(qreal dx, qreal dy) const |
QPolygonF | united(const QPolygonF &r) const |
QVariant | operator QVariant() const |
QDataStream & | operator<<(QDataStream &stream, const QPolygonF &polygon) |
QDataStream & | operator>>(QDataStream &stream, QPolygonF &polygon) |
A QPolygonF is a QList<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 QList, QPolygonF provides the boundingRect() and translate() functions for geometry operations. Use the QTransform::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 QList, QPolygon, and QLineF.
Constructs a float based polygon from the specified integer based polygon.
See also toPolygon().
Constructs a closed polygon from the specified rectangle.
The polygon contains the four vertices of the rectangle in clockwise order starting and ending with the top-left vertex.
See also isClosed().
Constructs a polygon containing the specified points.
Constructs a polygon with no points.
See also QList::isEmpty().
Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty.
See also QList::isEmpty().
Returns true
if the given point is inside the polygon according to the specified fillRule; otherwise returns false
.
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.
See also intersects().
[since 5.10]
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().
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 QList::first() and QList::last().
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.
Swaps polygon other with this polygon. This operation is very fast and never fails.
Creates and returns a QPolygon by converting each QPointF to a QPoint.
See also QPointF::toPoint().
Translate all points in the polygon by the given offset.
See also translated().
This is an overloaded function.
Translates all points in the polygon by (dx, dy).
See also translated().
Returns a copy of the polygon that is translated by the given offset.
See also translate().
This is an overloaded function.
Returns a copy of the polygon that is translated by (dx, dy).
See also translate().
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.
See also intersected() and subtracted().
Returns the polygon as a QVariant.
Writes the given polygon to the given stream, and returns a reference to the stream.
See also Serializing Qt Data Types.
Reads a polygon from the given stream into the given polygon, and returns a reference to the stream.
See also Serializing Qt Data Types.
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.2/qpolygonf.html