View Full Version : Autoscrolling of QGraphicsView while moving a QGraphicsitem

27th September 2011, 10:12

I am using a QGraphicsScene with some moveable QGraphicsItems. The scene is bigger than the view and screen.
How can I enable autoscrolling of the view when the user moves an item near the screen border???

Calling QGraphicsView::ensureVisible() in the MouseMoveEvent is not usefull solution, because it triggers always a vertical and horizontal scrollEvent.
Even the user moves the mouse strictly horizontal.


10th June 2014, 13:11
Dennis, you solved your problem? I have the same ...

10th June 2014, 19:15
In dragMoveEvent( QDragMoveEvent* e ) I detect if they are close to the edge of the viewport (you need to take account of the size of the scroll bars).

If they are close to the top I scroll up.
If they are close to the left side I scroll left.

I use a timer so that it only scrolls every x milliseconds.


10th June 2014, 21:48
The problem is, that I'm not using a drag-event. My item is not movable by QMouseEvent.

Would you be please so kind and show me some snippet of your code?
I appreciate your help.