Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Create clickable polygons

Create clickable polygons

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    felipe.c.sousa
    wrote on last edited by
    #1

    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?

    From all, to all.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        belab
        wrote on last edited by
        #3

        You can use QGraphicsScene all QGraphicsItems e.g. QSvgGraphicsItes are clickable out of the box.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jake007
          wrote on last edited by
          #4

          "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.


          Code is poetry

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved