PDA

View Full Version : Get informed when the scene is moved with QGraphicsView ScrollHandDrag drag mode



Lodorot
26th February 2010, 23:12
Hi,

I'm using the QGraphicsView dragMode ScrollHandDrag to move the visible part of the scene within my view by mouse dragging. Now I need a means to find out the new scene position at the center point of the view after such a move each time the scene has been moved. Is there any way to get informed when the scene has been moved by ScrollHandDrag?

Thanks

Lodorot

Bitto
4th March 2010, 17:32
I would reimplement QGraphicsView::scrollContentsBy() in a subclass of QGraphicsView and fish out the deltas. Or connect to the scrollbars to find when the scroll bar values have changed.

Lodorot
5th March 2010, 17:05
I hoped there would be a way without subclassing QGraphicsView.

I tried to connect to the scrollbars but the problem is I never know when the moving is finished. The dragging is done by scrolling. First the horizontalScrollBar is changed than the verticalScrollBar. But the scrollbar only signal if their values actually have been changed. So the dragging can stop with a horizontal or a vertical scrolling signal.

Regards

Lodorot

Urthas
29th March 2010, 19:55
What about creating a QPoint(yourView.width()/2, yourView.height/2) and feeding it to mapToScene()?