View Full Version : Prevent graphicsItem from being moved outside the boundary of defined scene

11th October 2009, 22:25
Hello All,

I'm writing an application that uses the QGraphicsRectItem as a base item of the scene, I can add to this item a QGraphicsPixmapItem items

The items that are added can be moved, but what I want is to prevent the user from being able to move the items outside the boundary of the base item of the scene, now the user can move the item everywhere, and outside the boundary of the base item

What do you suggest that I should do, is there any function that I need to re-implement or override?

Thanks very much!

12th October 2009, 13:26
See QGraphicsItem::itemChange() (http://doc.trolltech.com/4.5/qgraphicsitem.html#itemChange). The example should be exactly what you want.