Create clickable polygons
-
Hi, i want make a game using the Qt, for that i have to do clickable polygons, with the form i want. Somebody have any idea with how can i do that?
Is better i deform buttons? And how can i do that? -
Use linear algebra to test whether a point (where the cursor clicked) is inside a polygon.
One method: Define a ray starting at the point and count the intersections of the ray with the polygon sides. If the number of intersections is odd, the point is inside the polygon. Take care of some special cases, e.g. when the ray exactly goes through a corner of the polygon. -
You can use QGraphicsScene all QGraphicsItems e.g. QSvgGraphicsItes are clickable out of the box.
-
"QGraphicsPolygonItem":http://qt-project.org/doc/qt-4.8/qgraphicspolygonitem.html sounds like what you need.
There is an example usage in Diagram Scene Example.