# QPolygonF¶

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

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

```polygon = QPolygonF()
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 `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 .

`QVector` `QPolygon` `QLineF`

class `QPolygonF`

QPolygonF(v)

QPolygonF(a)

QPolygonF(a)

QPolygonF(r)

QPolygonF(v)

QPolygonF(size)

param size

`int`

param a

`QPolygon`

param r

`QRectF`

param v

`QVector`

Constructs a polygon with no points.

`isEmpty()`

Constructs a polygon of the given `size` . Creates an empty polygon if `size` == 0.

`isEmpty()`

`PySide2.QtGui.QPolygonF.``append`(t)
Parameters

t`QPointF`

`PySide2.QtGui.QPolygonF.``append`(t)
Parameters

t`QPointF`

`PySide2.QtGui.QPolygonF.``append`(l)
Parameters

l

`PySide2.QtGui.QPolygonF.``at`(i)
Parameters

i`int`

Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``back`()
Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``boundingRect`()
Return type

`QRectF`

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

`isEmpty()`

`PySide2.QtGui.QPolygonF.``capacity`()
Return type

`int`

`PySide2.QtGui.QPolygonF.``clear`()
`PySide2.QtGui.QPolygonF.``constData`()
Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``constFirst`()
Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``constLast`()
Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``contains`(t)
Parameters

t`QPointF`

Return type

`bool`

`PySide2.QtGui.QPolygonF.``containsPoint`(pt, fillRule)
Parameters
• pt`QPointF`

• fillRule`FillRule`

Return type

`bool`

Returns `true` if the given `point` is inside the polygon according to the specified `fillRule` ; otherwise returns `false` .

`PySide2.QtGui.QPolygonF.``count`()
Return type

`int`

`PySide2.QtGui.QPolygonF.``count`(t)
Parameters

t`QPointF`

Return type

`int`

`PySide2.QtGui.QPolygonF.``data`()
Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``empty`()
Return type

`bool`

`PySide2.QtGui.QPolygonF.``endsWith`(t)
Parameters

t`QPointF`

Return type

`bool`

`PySide2.QtGui.QPolygonF.``fill`(t[, size=-1])
Parameters
• t`QPointF`

• size`int`

Return type

`PySide2.QtGui.QPolygonF.``first`()
Return type

`QPointF`

static `PySide2.QtGui.QPolygonF.``fromList`(list)
Parameters

list

Return type

`PySide2.QtGui.QPolygonF.``front`()
Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``indexOf`(t[, from=0])
Parameters
• t`QPointF`

• from`int`

Return type

`int`

`PySide2.QtGui.QPolygonF.``insert`(i, t)
Parameters
• i`int`

• t`QPointF`

`PySide2.QtGui.QPolygonF.``insert`(i, t)
Parameters
• i`int`

• t`QPointF`

`PySide2.QtGui.QPolygonF.``insert`(i, n, t)
Parameters
• i`int`

• n`int`

• t`QPointF`

`PySide2.QtGui.QPolygonF.``intersected`(r)
Parameters
Return type

`QPolygonF`

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.

`PySide2.QtGui.QPolygonF.``intersects`(r)
Parameters
Return type

`bool`

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.

`PySide2.QtGui.QPolygonF.``isClosed`()
Return type

`bool`

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.

`first()` `last()`

`PySide2.QtGui.QPolygonF.``isEmpty`()
Return type

`bool`

`PySide2.QtGui.QPolygonF.``isSharedWith`(other)
Parameters

other

Return type

`bool`

`PySide2.QtGui.QPolygonF.``last`()
Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``lastIndexOf`(t[, from=-1])
Parameters
• t`QPointF`

• from`int`

Return type

`int`

`PySide2.QtGui.QPolygonF.``length`()
Return type

`int`

`PySide2.QtGui.QPolygonF.``mid`(pos[, len=-1])
Parameters
• pos`int`

• len`int`

Return type

`PySide2.QtGui.QPolygonF.``move`(from, to)
Parameters
• from`int`

• to`int`

`PySide2.QtGui.QPolygonF.``__ne__`(v)
Parameters

v

Return type

`bool`

`PySide2.QtGui.QPolygonF.``__mul__`(m)
Parameters
Return type

`QPolygonF`

`PySide2.QtGui.QPolygonF.``__mul__`(m)
Parameters
Return type

`QPolygonF`

`PySide2.QtGui.QPolygonF.``__add__`(l)
Parameters

l

Return type

`PySide2.QtGui.QPolygonF.``__iadd__`(t)
Parameters

t`QPointF`

Return type

`PySide2.QtGui.QPolygonF.``__iadd__`(t)
Parameters

t`QPointF`

Return type

`PySide2.QtGui.QPolygonF.``__lshift__`(t)
Parameters

t`QPointF`

Return type

`PySide2.QtGui.QPolygonF.``__eq__`(v)
Parameters

v

Return type

`bool`

`PySide2.QtGui.QPolygonF.operator[](i)`
Parameters

i`int`

Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``pop_back`()
`PySide2.QtGui.QPolygonF.``pop_front`()
`PySide2.QtGui.QPolygonF.``prepend`(t)
Parameters

t`QPointF`

`PySide2.QtGui.QPolygonF.``prepend`(t)
Parameters

t`QPointF`

`PySide2.QtGui.QPolygonF.``push_back`(t)
Parameters

t`QPointF`

`PySide2.QtGui.QPolygonF.``push_back`(t)
Parameters

t`QPointF`

`PySide2.QtGui.QPolygonF.``push_front`(t)
Parameters

t`QPointF`

`PySide2.QtGui.QPolygonF.``push_front`(t)
Parameters

t`QPointF`

`PySide2.QtGui.QPolygonF.``remove`(i)
Parameters

i`int`

`PySide2.QtGui.QPolygonF.``remove`(i, n)
Parameters
• i`int`

• n`int`

`PySide2.QtGui.QPolygonF.``removeAll`(t)
Parameters

t`QPointF`

Return type

`int`

`PySide2.QtGui.QPolygonF.``removeAt`(i)
Parameters

i`int`

`PySide2.QtGui.QPolygonF.``removeFirst`()
`PySide2.QtGui.QPolygonF.``removeLast`()
`PySide2.QtGui.QPolygonF.``removeOne`(t)
Parameters

t`QPointF`

Return type

`bool`

`PySide2.QtGui.QPolygonF.``replace`(i, t)
Parameters
• i`int`

• t`QPointF`

`PySide2.QtGui.QPolygonF.``reserve`(size)
Parameters

size`int`

`PySide2.QtGui.QPolygonF.``resize`(size)
Parameters

size`int`

`PySide2.QtGui.QPolygonF.``setSharable`(sharable)
Parameters

sharable`bool`

`PySide2.QtGui.QPolygonF.``shrink_to_fit`()
`PySide2.QtGui.QPolygonF.``size`()
Return type

`int`

`PySide2.QtGui.QPolygonF.``squeeze`()
`PySide2.QtGui.QPolygonF.``startsWith`(t)
Parameters

t`QPointF`

Return type

`bool`

`PySide2.QtGui.QPolygonF.``subtracted`(r)
Parameters
Return type

`QPolygonF`

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.

`PySide2.QtGui.QPolygonF.``swap`(other)
Parameters

other`QPolygonF`

Swaps polygon `other` with this polygon. This operation is very fast and never fails.

`PySide2.QtGui.QPolygonF.``takeAt`(i)
Parameters

i`int`

Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``takeFirst`()
Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``takeLast`()
Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``toList`()
Return type

`PySide2.QtGui.QPolygonF.``toPolygon`()
Return type

`QPolygon`

Creates and returns a `QPolygon` by converting each `QPointF` to a `QPoint` .

`toPoint()`

`PySide2.QtGui.QPolygonF.``translate`(offset)
Parameters

offset`QPointF`

Translate all points in the polygon by the given `offset` .

`PySide2.QtGui.QPolygonF.``translate`(dx, dy)
Parameters
• dx`qreal`

• dy`qreal`

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

`PySide2.QtGui.QPolygonF.``translated`(offset)
Parameters

offset`QPointF`

Return type

`QPolygonF`

Returns a copy of the polygon that is translated by the given `offset` .

`PySide2.QtGui.QPolygonF.``translated`(dx, dy)
Parameters
• dx`qreal`

• dy`qreal`

Return type

`QPolygonF`

Returns a copy of the polygon that is translated by (`dx` , `dy` ).

`PySide2.QtGui.QPolygonF.``united`(r)
Parameters
Return type

`QPolygonF`

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.

`PySide2.QtGui.QPolygonF.``value`(i)
Parameters

i`int`

Return type

`QPointF`

`PySide2.QtGui.QPolygonF.``value`(i, defaultValue)
Parameters
• i`int`

• defaultValue`QPointF`

Return type

`QPointF`