So im trying to use the drawPolygon() function to draw some shapes in a plot. After a lot of trouble I tried painting this two polygons, the first one does not work and the second one yes:
points1 = QPolygon([
QPoint(0,0),
QPoint(0,0.5),
QPoint(0.5,0.5),
QPoint(0.5,0)])
points2 = QPolygon([
QPoint(0,0),
QPoint(0,1),
QPoint(1,1),
QPoint(1,0)])
p.drawPolygon(points1)
#p.drawPolygon(points2)
p.end()
Is something with the drawPolygon function that cant draw a smaller polygon than 1 unit?
I tried to draw a polygon with Qpolygon function. I came up with the problem of not being able to draw a smaller polygon than 1 unit
QPolygon
and QPoint
have integer precision
So QPoint(0, 0.5)
is actually QPoint(0, 0)
, and your polygon results in 4 congruent points
What should be used are their floating-point versions: QPolygonF
and QPointF