Results 1 to 2 of 2

Thread: QpolygonF: order of points

  1. #1
    Join Date
    Apr 2011
    Posts
    3
    Thanked 1 Time in 1 Post

    Default QpolygonF: order of points

    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!

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,348
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: QpolygonF: order of points

    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.

Similar Threads

  1. Replies: 2
    Last Post: 2nd May 2012, 10:49
  2. Limitations to QPolygonF?
    By roband915 in forum Qt Programming
    Replies: 12
    Last Post: 24th May 2011, 15:55
  3. QPolygonF created from QRectF has five(?!) points
    By Asperamanca in forum Qt Programming
    Replies: 6
    Last Post: 2nd April 2011, 17:55
  4. QPolygonF precision?! is it possible?!
    By fatecasino in forum Newbie
    Replies: 11
    Last Post: 27th January 2011, 03:36
  5. Sorting QPolygonF
    By giusepped in forum Qt Programming
    Replies: 3
    Last Post: 7th January 2009, 09:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.