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. I have Qgraphicsview object , I have used drawPolygons now I want check if the point x1 y1 is inside a polygon or not

I have Qgraphicsview object , I have used drawPolygons now I want check if the point x1 y1 is inside a polygon or not

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 2.0k Views
  • 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by Qt Enthusiast
    #1

    Now I have a point I want to check if the Point (x1,y1) is inside the polygon boundary

    jsulmJ 1 Reply Last reply
    0
    • Q Qt Enthusiast

      Now I have a point I want to check if the Point (x1,y1) is inside the polygon boundary

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Qt-Enthusiast This is now the third post with the same question!
      Please stop asking same question several times!

      What is exactly the problem? QPolygon provides containsPoint() method which does exactly what you want to do:

      QPoint p(10, 10);
      if (polygon.containsPoint(p, Qt::OddEvenFill))
          qDebug() << "inside";
      else
          qDebug() << "not inside";
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4
      • Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by
        #3

        What is Qt::OddEvenFill) stands for ?
        Also for points on the boundary of the polygon , the containsPoint returns false . but as per my application the points on the boundary of the polygon are outside the polygon .What is the solution to fix this

        jsulmJ 1 Reply Last reply
        0
        • BjornWB Offline
          BjornWB Offline
          BjornW
          wrote on last edited by
          #4

          You need to learn to use the documentation.

          http://doc.qt.io/qt-5/qt.html#FillRule-enum

          Also, beware that "for points on the boundary", are basically none-existant due to rounding errors in any floating point model. "near the boundary" is about as close as you can get.

          Q 1 Reply Last reply
          3
          • Q Qt Enthusiast

            What is Qt::OddEvenFill) stands for ?
            Also for points on the boundary of the polygon , the containsPoint returns false . but as per my application the points on the boundary of the polygon are outside the polygon .What is the solution to fix this

            jsulmJ Online
            jsulmJ Online
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Qt-Enthusiast I agree with @BjornW : you should really start to read the documentation! What you asked is described there, but you are asking other people to spend their time to explain it. It is OK to ask if you do not understand the description in the documentation, but please try to read and understand the documentation first!

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            Q 1 Reply Last reply
            2
            • jsulmJ jsulm

              @Qt-Enthusiast I agree with @BjornW : you should really start to read the documentation! What you asked is described there, but you are asking other people to spend their time to explain it. It is OK to ask if you do not understand the description in the documentation, but please try to read and understand the documentation first!

              Q Offline
              Q Offline
              Qt Enthusiast
              wrote on last edited by
              #6

              @jsulm

              My apologies for the same and I will take of the same in the future

              1 Reply Last reply
              0
              • BjornWB BjornW

                You need to learn to use the documentation.

                http://doc.qt.io/qt-5/qt.html#FillRule-enum

                Also, beware that "for points on the boundary", are basically none-existant due to rounding errors in any floating point model. "near the boundary" is about as close as you can get.

                Q Offline
                Q Offline
                Qt Enthusiast
                wrote on last edited by
                #7

                @BjornW
                I went through http://doc.qt.io/qt-5/qt.html#FillRule-enum but I still have questions

                When to use Qt::OddEvenFill and when to use Qt::WindingFill . What is pros/cons using one fillRule over other

                1 Reply Last reply
                0
                • BjornWB Offline
                  BjornWB Offline
                  BjornW
                  wrote on last edited by
                  #8

                  I don't know it any better than what was documented, sorry. Did you try the code @jsulm wrote? Does it work?

                  1 Reply Last reply
                  0
                  • VRoninV Offline
                    VRoninV Offline
                    VRonin
                    wrote on last edited by VRonin
                    #9

                    http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/

                    Just leave the argument omitted (defaults to odd-even)

                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                    ~Napoleon Bonaparte

                    On a crusade to banish setIndexWidget() from the holy land of Qt

                    1 Reply Last reply
                    2

                    • Login

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