PDA

View Full Version : QpolygonF: order of points



giostau
11th April 2013, 13:49
Hi to all!

maybe my question is stupid, but i'm stuck for a while with this.... :(

I want to create a QpolygonF from a set of points...
The problem is that the order of the points i have is wrong, and the polygon is created wrong.
i.e. instead of a square, i get a double-z-like shape (i mean that the horizontal lines are ok, but instead of the vertical ones, i get two diagonal...)

when i try to draw polygons with more that 4 points, things are much worse....

how can i fix this?

Thank you in advance!

d_stranz
11th April 2013, 17:46
You have to create your QPolygon points in the order that you would see them if you started walking at one vertex of your polygon and walked around the outside edge. As you reach each new vertex, add it to the list of points. Since Qt is mostly a 2-D coordinate system, it does not matter which way you walk around the polygon. In a 3-D system (like OpenGL), it does matter because if you walk in one direction you are defining the front face of the polygon, and it you walk the other way, it defines the back face. So if you intend to do 3-D graphics some day, pick the direction that defines a front-facing walk.