Autoscrolling of QGraphicsView while moving a QGraphicsitem
Hi,
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.
greets,
Dennis
Re: Autoscrolling of QGraphicsView while moving a QGraphicsitem
Dennis, you solved your problem? I have the same ...
Re: Autoscrolling of QGraphicsView while moving a QGraphicsitem
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.
etc
I use a timer so that it only scrolls every x milliseconds.
HTH
Re: Autoscrolling of QGraphicsView while moving a QGraphicsitem
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.