- class QPolygon¶
The
QPolygon
class provides a list of points using integer precision. More…Synopsis¶
Methods¶
def
__init__()
def
__reduce__()
def
append()
def
at()
def
back()
def
boundingRect()
def
capacity()
def
clear()
def
constData()
def
constFirst()
def
constLast()
def
containsPoint()
def
count()
def
data()
def
empty()
def
first()
def
front()
def
insert()
def
intersected()
def
intersects()
def
isEmpty()
def
isSharedWith()
def
last()
def
length()
def
max_size()
def
mid()
def
move()
def
__ne__()
def
__mul__()
def
__add__()
def
__lshift__()
def
__eq__()
def
operator[]()
def
pop_back()
def
pop_front()
def
prepend()
def
push_back()
def
push_front()
def
remove()
def
removeAll()
def
removeAt()
def
removeFirst()
def
removeLast()
def
removeOne()
def
reserve()
def
resize()
def
shrink_to_fit()
def
size()
def
sliced()
def
squeeze()
def
subtracted()
def
swap()
def
swapItemsAt()
def
takeAt()
def
toList()
def
toPolygonF()
def
toVector()
def
translate()
def
translated()
def
united()
def
value()
Static functions¶
def
fromList()
def
fromVector()
def
maxSize()
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
QPolygon
object is a QList<QPoint>. The easiest way to add points to aQPolygon
is to use QList’s streaming operator, as illustrated below:polygon = QPolygon() polygon << QPoint(10, 20) << QPoint(20, 30)
In addition to the functions provided by QList,
QPolygon
provides some point-specific functions.Each point in a polygon can be retrieved by passing its index to the
point()
function. To populate the polygon,QPolygon
provides thesetPoint()
function to set the point at a given index, thesetPoints()
function to set all the points in the polygon (resizing it to the given number of points), and theputPoints()
function which copies a number of given points into the polygon from a specified index (resizing the polygon if necessary).QPolygon
provides theboundingRect()
andtranslate()
functions for geometry functions. Use themap()
function for more general transformations of QPolygons.The
QPolygon
class is implicitly shared.- __init__()¶
Constructs a polygon with no points.
See also
isEmpty()
- __init__(v)
- Parameters:
v – .list of QPoint
Constructs a polygon containing the specified
points
.See also
setPoints()
- __init__(r[, closed=false])
- Parameters:
r –
QRect
closed – bool
Constructs a polygon from the given
rectangle
. Ifclosed
is false, the polygon just contains the four points of the rectangle ordered clockwise, otherwise the polygon’s fifth point is set torectangle
.topLeft().Note that the bottom-right corner of the rectangle is located at (rectangle.x() + rectangle.width(), rectangle.y() + rectangle.height()).
See also
setPoints()
- __reduce__()¶
- Return type:
str
- append(l)
- Parameters:
l – .list of QPoint
Returns the bounding rectangle of the polygon, or QRect(0, 0, 0, 0) if the polygon is empty.
See also
isEmpty()
- capacity()¶
- Return type:
int
- clear()¶
Returns
true
if the givenpoint
is inside the polygon according to the specifiedfillRule
; otherwise returnsfalse
.- count()¶
- Return type:
int
- empty()¶
- Return type:
bool
- first(n)
- Parameters:
n – int
- Return type:
.list of QPoint
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
Returns
true
if the current polygon intersects at any point the given polygonp
. Also returnstrue
if the current polygon contains or is contained by any part ofp
.Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.
See also
- isEmpty()¶
- Return type:
bool
- Parameters:
other – .list of QPoint
- Return type:
bool
- last(n)
- Parameters:
n – int
- Return type:
.list of QPoint
- length()¶
- Return type:
int
- static maxSize()¶
- Return type:
int
- max_size()¶
- Return type:
int
- move(from, to)¶
- Parameters:
from – int
to – int
- __mul__(m)¶
- Parameters:
m –
QTransform
- Return type:
- __lshift__(arg__1)¶
- Parameters:
arg__1 – .list of QPoint
- __lshift__(arg__1)
- Parameters:
arg__1 –
QPoint
- pop_back()¶
- pop_front()¶
- remove(i[, n=1])¶
- Parameters:
i – int
n – int
- removeAt(i)¶
- Parameters:
i – int
- removeFirst()¶
- removeLast()¶
- reserve(size)¶
- Parameters:
size – int
- resize(size)¶
- Parameters:
size – int
- resizeForOverwrite(size)¶
- Parameters:
size – int
- shrink_to_fit()¶
- size()¶
- Return type:
int
- sliced(pos, n)
- Parameters:
pos – int
n – int
- Return type:
.list of QPoint
- squeeze()¶
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.- swapItemsAt(i, j)¶
- Parameters:
i – int
j – int
Returns this polygon as a polygon with floating point accuracy.
See also
This is an overloaded function.
Translates all points in the polygon by the given
offset
.See also
- translate(dx, dy)
- Parameters:
dx – int
dy – int
Translates all points in the polygon by (
dx
,dy
).See also
This is an overloaded function.
Returns a copy of the polygon that is translated by the given
offset
.See also
- translated(dx, dy)
- Parameters:
dx – int
dy – int
- Return type:
Returns a copy of the polygon that is translated by (
dx
,dy
).See also
Returns a polygon which is the union of this polygon and
r
.Set operations on polygons, will treat the polygons as areas, and implicitly close the polygon.
See also