class QPolygonF#

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

# Synopsis#

## Static functions#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

# Detailed Description#

Warning

This section contains snippets that were automatically translated from C++ to Python and may contain errors.

A `QPolygonF` is a QList<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 QList, `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.

See also

__init__(v)#
Parameters:

v – .list of QPointF

Constructs a polygon containing the specified `points`.

__init__()

Constructs a polygon with no points.

See also

`isEmpty()`

__init__(r)
Parameters:

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.

__init__(a)
Parameters:

Constructs a float based polygon from the specified integer based `polygon`.

append(arg__1)#
Parameters:

arg__1`QPointF`

append(l)
Parameters:

l – .list of QPointF

at(i)#
Parameters:

i – int

Return type:

`QPointF`

back()#
Return type:

`QPointF`

boundingRect()#
Return type:

`QRectF`

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

See also

`isEmpty()`

capacity()#
Return type:

int

clear()#
constData()#
Return type:

`QPointF`

constFirst()#
Return type:

`QPointF`

constLast()#
Return type:

`QPointF`

containsPoint(pt, fillRule)#
Parameters:
Return type:

bool

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

count()#
Return type:

int

data()#
Return type:

`QPointF`

empty()#
Return type:

bool

first(n)#
Parameters:

n – int

Return type:

.list of QPointF

first()
Return type:

`QPointF`

static fromList(list)#
Parameters:

list – .list of QPointF

Return type:

.list of QPointF

static fromVector(vector)#
Parameters:

vector – .list of QPointF

Return type:

.list of QPointF

front()#
Return type:

`QPointF`

insert(arg__1, arg__2)#
Parameters:
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.

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.

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.

See also

`last()`

isEmpty()#
Return type:

bool

isSharedWith(other)#
Parameters:

other – .list of QPointF

Return type:

bool

last()#
Return type:

`QPointF`

last(n)
Parameters:

n – int

Return type:

.list of QPointF

length()#
Return type:

int

mid(pos[, len=-1])#
Parameters:
• pos – int

• len – int

Return type:

.list of QPointF

move(from, to)#
Parameters:
• from – int

• to – int

__mul__(m)#
Parameters:
Return type:

`QPolygonF`

__add__(l)#
Parameters:

l – .list of QPointF

Return type:

.list of QPointF

operator(i)#
Parameters:

i – int

Return type:

`QPointF`

pop_back()#
pop_front()#
prepend(arg__1)#
Parameters:

arg__1`QPointF`

push_back(arg__1)#
Parameters:

arg__1`QPointF`

push_front(arg__1)#
Parameters:

arg__1`QPointF`

remove(i[, n=1])#
Parameters:
• i – int

• n – int

removeAll(arg__1)#
Parameters:

arg__1`QPointF`

removeAt(i)#
Parameters:

i – int

removeFirst()#
removeLast()#
removeOne(arg__1)#
Parameters:

arg__1`QPointF`

reserve(size)#
Parameters:

size – int

resize(size)#
Parameters:

size – int

shrink_to_fit()#
size()#
Return type:

int

sliced(pos)#
Parameters:

pos – int

Return type:

.list of QPointF

sliced(pos, n)
Parameters:
• pos – int

• n – int

Return type:

.list of QPointF

squeeze()#
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.

swap(other)#
Parameters:

other`QPolygonF`

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

swapItemsAt(i, j)#
Parameters:
• i – int

• j – int

takeAt(i)#
Parameters:

i – int

Return type:

`QPointF`

toList()#
Return type:

.list of QPointF

toPolygon()#
Return type:

`QPolygon`

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

toVector()#
Return type:

.list of QPointF

translate(offset)#
Parameters:

offset`QPointF`

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

translate(dx, dy)
Parameters:
• dx – float

• dy – float

This is an overloaded function.

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

translated(offset)#
Parameters:

offset`QPointF`

Return type:

`QPolygonF`

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

translated(dx, dy)
Parameters:
• dx – float

• dy – float

Return type:

`QPolygonF`

This is an overloaded function.

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

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.

value(i)#
Parameters:

i – int

Return type:

`QPointF`