PDA

View Full Version : Stop movement of QGraphicsItems on scene in ScrollHandDrag mode of QGraphicsView.



anwar.qt
28th September 2012, 12:15
I have multiple QGraphicsItems in scene spread across different parts of scene. In application there are different modes in one of mode user can scroll the scene (palm drag mode).
To achieve scrolling over scene I set dragMode of QGraphicsView to ScrollHandDrag.

But the problem is when user try to scroll over scene by dragging (MousePress and MouseMove) on any of QGraphicsItem instead of scrolling scene it moves QGraphicsItem.


How can I stop movement of QGraphicsItem and scroll the scene, but I still want to select QGraphicsItems?


NOTE : There are very large number of QGraphicsItems and are of various type.
So It is not possible to install event filter on QGraphicsItems.

wysota
5th October 2012, 00:52
Reimplement mouse events for the view, only call the base class implementation if you want the items to be movable (i.e. when not in scroll mode). Alternatively while the drag is occuring, remove the unwanted flags (like movable, selectable) from the item under cursor. Just first make sure that a minimal example also reproduces your problem.

anwar.qt
17th October 2012, 11:20
Thank You!! Solution Works.

anwar.qt
25th April 2013, 09:32
I posted the same issue in an another forum. I got some useful replies. Click here (http://stackoverflow.com/questions/12928190/in-scrollhanddrag-mode-of-qgraphicsview-how-to-stop-movement-of-qgraphicsitems/16150470?noredirect=1#16150470) to view.

Setting QGraphicsView interactive to false works Fine!! :)