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. Collision of items

Collision of items

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 267 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.
  • D Offline
    D Offline
    DiZhu
    wrote last edited by
    #1

    When I drag polygon A to move, if I collide with another polygon B, then how can I make polygon A not overlap polygon B and drag polygon A along the outer contour of polygon B?

    1 Reply Last reply
    0
    • Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote last edited by
      #2

      Are you using QtQuick or widgets?
      And what exactly do you mean by

      along the outer contour of polygon B?

      Do you want to restrict the move? Or continue to move A, while the mouse is over B?

      Software Engineer
      The Qt Company, Oslo

      JoeCFDJ D 2 Replies Last reply
      0
      • Axel SpoerlA Axel Spoerl

        Are you using QtQuick or widgets?
        And what exactly do you mean by

        along the outer contour of polygon B?

        Do you want to restrict the move? Or continue to move A, while the mouse is over B?

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote last edited by JoeCFD
        #3

        @Axel-Spoerl i guess what he meant is to move A around B, not across B. It is more a geometry issue than Qt problem. Override paint func in QWidget. Need to know how he draws polygons in QML.

        1 Reply Last reply
        0
        • Axel SpoerlA Offline
          Axel SpoerlA Offline
          Axel Spoerl
          Moderators
          wrote last edited by
          #4

          Interesting problem. So A should deviate from the original draw path to avoid collision with B?

          Software Engineer
          The Qt Company, Oslo

          1 Reply Last reply
          0
          • JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote last edited by JoeCFD
            #5
            This post is deleted!
            JoeCFDJ 1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

              This post is deleted!

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote last edited by
                #7

                Ask grok or deepseek about how
                move a polygon A on a 2D plane. How to move A around polygon B, not across B in Qt widget or QML

                D 1 Reply Last reply
                0
                • Axel SpoerlA Axel Spoerl

                  Are you using QtQuick or widgets?
                  And what exactly do you mean by

                  along the outer contour of polygon B?

                  Do you want to restrict the move? Or continue to move A, while the mouse is over B?

                  D Offline
                  D Offline
                  DiZhu
                  wrote last edited by
                  #8

                  @Axel-Spoerl Hi,My friend.This is a question about QGraphicsItem. JoeCFD's reply is correct. Additionally, I hope to achieve that when there is a hole in ItemA that is larger than ItemB, I can drag ItemB to move within this hole, and of course, it should also be possible to move around the hole inside212.png .

                  1 Reply Last reply
                  0
                  • JoeCFDJ JoeCFD

                    Ask grok or deepseek about how
                    move a polygon A on a 2D plane. How to move A around polygon B, not across B in Qt widget or QML

                    D Offline
                    D Offline
                    DiZhu
                    wrote last edited by
                    #9

                    @JoeCFD Hi,Thanks for your reply.I have already implemented this function using the GJK algorithm, in fact, I just want to know if there is a way to implement this function in QT. Since QGraphicsItem has a collision function, I was wondering if QGraphicsItem has a way to achieve my goal that I don't know yet?

                    JoeCFDJ 1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      Kevin Hoang
                      wrote last edited by
                      #10

                      By default, Qt allows moving selected items, not just a single item. If you want to check for collisions or limit how far items can move, you’ll need to subclass QGraphicsScene and handle that logic there.

                      But if you only have one movable item, you can simply override the itemChange event in your item class to restrict its movement.

                      1 Reply Last reply
                      1
                      • D DiZhu

                        @JoeCFD Hi,Thanks for your reply.I have already implemented this function using the GJK algorithm, in fact, I just want to know if there is a way to implement this function in QT. Since QGraphicsItem has a collision function, I was wondering if QGraphicsItem has a way to achieve my goal that I don't know yet?

                        JoeCFDJ Offline
                        JoeCFDJ Offline
                        JoeCFD
                        wrote last edited by JoeCFD
                        #11

                        @DiZhu if you read the docu, you may realize that the collides funcs of QGraphicsItem use bounding boxes of items to detect collision and this may not fit your app. If you have only triangles, it might be relatively easy for you to implement more accurate methods for collision detection. But it can be tough to handle all shapes of polygons.

                        1 Reply Last reply
                        1

                        • Login

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