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
QtWS25 Last Chance

Collision of items

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 266 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 26 days ago 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
    • A Online
      A Online
      Axel Spoerl
      Moderators
      wrote 26 days ago 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

      J D 2 Replies Last reply 26 days ago
      0
      • A Axel Spoerl
        26 days ago

        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?

        J Offline
        J Offline
        JoeCFD
        wrote 26 days ago 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
        • A Online
          A Online
          Axel Spoerl
          Moderators
          wrote 26 days ago 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
          • J Offline
            J Offline
            JoeCFD
            wrote 26 days ago last edited by JoeCFD
            #5
            This post is deleted!
            J 1 Reply Last reply 26 days ago
            0
            • J JoeCFD
              26 days ago

              This post is deleted!

              J Offline
              J Offline
              JoeCFD
              wrote 26 days ago last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • J Offline
                J Offline
                JoeCFD
                wrote 26 days ago 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 25 days ago
                0
                • A Axel Spoerl
                  26 days ago

                  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 25 days ago 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
                  • J JoeCFD
                    26 days ago

                    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 25 days ago 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?

                    J 1 Reply Last reply 25 days ago
                    0
                    • K Offline
                      K Offline
                      Kevin Hoang
                      wrote 25 days ago 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
                        25 days ago

                        @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?

                        J Offline
                        J Offline
                        JoeCFD
                        wrote 25 days ago 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

                        1/11

                        16 Apr 2025, 10:14

                        • Login

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