PDA

View Full Version : QGraphicsItem Movable



QbelcorT
12th March 2009, 11:46
Hi,
I have a QGraphicsItem that is movable. Do I need to update the bounding rectangle of that item when it is moved to a new position? (i.e location). If so, what is the best method in doing this?
Sometimes the item stays at the position, but other times when I click on it again it jumps back to it's old location.

Thanks in advance.

wysota
12th March 2009, 11:56
No, the bounding rect is always constant - it denotes the range of local coordinates an item can take and it has nothing to do with position of the item on the scene. For instance if you have an item that displays a pixmap that is 400x300px large, you will set the bounding rect of the item to (0,0,400,300) regardless of the final position of the item on the scene - be it lower right corner, centre or upper left corner of the scene. The latter is determined by the position of the item and that is what is changed when you mark an item movable and request GraphicsView to handle its movements for you.