Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In ScrollHandDrag mode of QGraphicsView, How to stop movement of QGraphicsItems on scene?

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?

Any Solution or any pointers will help.

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

like image 233
Anwar Shaikh Avatar asked Oct 17 '12 06:10

Anwar Shaikh


1 Answers

Instead of modifying the item flags I set the whole view not interactive while in ScrollHandDrag Mode. The problem is, that you need to have an additional interaction type (i.e. Control Key, Other Mouse Button etc) to enable it.

setDragMode(ScrollHandDrag);
setInteractive(false);
like image 176
FSaccilotto Avatar answered Oct 22 '22 02:10

FSaccilotto