Results 1 to 5 of 5

Thread: determining collision of item groups

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

    Default Re: determining collision of item groups

    Since the OP hasn't posted anything here in over 7 years, I doubt he is going to answer your question.

    As the OP states, QGraphicsItem::collidesWithItem() will probably not work well, since it uses the bounding rectangles for each of the groups. You could try using the QGraphicsItem::boundingRegion() method to retrieve the QRegion for each group and calling QRegion::intersects() to see if the two QRegions are overlapping. However, QGraphicsItemGroup does not re-implement boundingRegion(), so it might simply return boundingRect() as a QRegion so you would be out of luck there. You will have to test this.

    If you have to look at each child item inside the two groups, you can do a little bit of optimizing. If collidesWithItem() return false, then you know that there cannot be any collision between any child items in the groups.

    If there is a collision between the two groups, you do not have to examine every pair of children in each group. You have to examine only the children which lie within the intersection of the two group bounding rects (QRectF::intersected()).
    Last edited by d_stranz; 29th November 2017 at 22:47.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Determining the height of an item in a QListWidget
    By negritot in forum Qt Programming
    Replies: 5
    Last Post: 13th May 2009, 19:18
  2. View, Scene, Item and thread??
    By dungsivn in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 19:21
  3. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.