Overlapping labels in Qt fridge magnets example

Posted by bullettime on Stack Overflow See other posts from Stack Overflow or by bullettime
Published on 2010-02-24T18:31:48Z Indexed on 2010/03/22 12:51 UTC
Read the original article Hit count: 323

I want to modify the fridge magnets example provided with Qt in a way that when I drag a label and drop it over another, it will push the label beneath the dragged label to the side, so they will never overlap one another.

I've seen how collision is detected in the colliding mice example, where it uses a QGraphicsScene to draw the QGraphicsItem mice on, and scene()->collidingItems(this) to see which mice are colliding.

The problem is that the fridge magnets example uses a class that inherits QWidget in place of QGraphicsScene, so there's no collidingItems() method to check when we have a collision.

How do I go about doing that?

© Stack Overflow or respective owner

Related posts about qt

Related posts about drag-and-drop