View Full Version : How to know when the user scroll through or is panning the QGraphicsView

19th July 2010, 06:44

I am using QGraphicsView to display my UI.

The UI is big enough to show the scrollbar and I also have view's drag mode set to panning. Now how can I know when the user is scrolling though the view or panning through the view? What signal is emitted or what event should I override?


20th July 2010, 13:16
Hi ,

You can have set one of the following possible drags

View.setDragMode(QGraphicsView::ScrollHandDrag orQGraphicsView::RubberBandDrag);

In QGraphicsView::ScrollHandDrag ,The cursor changes into a pointing hand, and dragging the mouse around will scroll the scrolbars. This mode works both in interactive and non-interactive mode.

In orQGraphicsView::RubberBandDrag A rubber band will appear. Dragging the mouse will set the rubber band geometry, and all items covered by the rubber band are selected. This mode is disabled for non-interactive views.

Alternatively if you want override any of the events related to Viewport you can use : QAbstractScrollArea::viewportEvent().

Hope this helps.