Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

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

    General and Desktop
    4
    9
    1635
    Loading More Posts
    • 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
      Qt Enthusiast last edited by Qt Enthusiast

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

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @Qt Enthusiast last edited by

        @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 Reply Quote 4
        • Q
          Qt Enthusiast last edited by

          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

          jsulm 1 Reply Last reply Reply Quote 0
          • BjornW
            BjornW last edited by

            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 Reply Quote 3
            • jsulm
              jsulm Lifetime Qt Champion @Qt Enthusiast last edited by

              @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 Reply Quote 2
              • Q
                Qt Enthusiast @jsulm last edited by

                @jsulm

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

                1 Reply Last reply Reply Quote 0
                • Q
                  Qt Enthusiast @BjornW last edited by

                  @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 Reply Quote 0
                  • BjornW
                    BjornW last edited by

                    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 Reply Quote 0
                    • VRonin
                      VRonin last edited by VRonin

                      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 Reply Quote 2
                      • First post
                        Last post