Re: QGrapghicsView updating
Why are you changing the scene rect?
Don't you need QGraphicsView::fitInView instead?
Be carefut that QGraphicsView::sceneRect does not returns the visible rect in the view.
I have same needs and I didn't find better to get it than :
Code:
mapToScene(viewport()->rect())
How is update your variable pan_rect?
Be aware than when you code will work, the return coordinates of
Code:
mapToScene(event->pos())
will have same value in mousePress and mouseMove,
by definition of the pan : the pixel coordinates change, but scene coordinates are attach to the mouse!!
And last but not least : are you aware of QGraphicsView::setDragMode with QGraphicsView::ScrollHandDrag?
Re: QGrapghicsView updating
The problem is not the coordinates. All the coords are checked to be fine.
The problem is that the calls
translate()
or
centerOn()
didn't move the view...
For example If I put in mouseMoveEvent the call translate(10,10) it will not move the view.
The only call that I have found to move the view is the setSceneRect(), although in documentation it implies that this is not the view piece of the scene, it's the entire scene. In practise it seems to be the viewable rect of the scene.
Am I missing something about the QGraphicsView structure?
When I call translate, rotate etc etc , view is not updated? Why? And how can I do it?
I am at the begining of a project. It's my first use of QGraphicsView/Scene and I have to clear out all the above, before I move on with my work...
Re: QGrapghicsView updating
Ok I think I see what is happening
You cannot set the view of the scene outside the sceneRect.
The result of the view changes will be block to the closest part of the rect scene.
That is why, when you change the scene rect, you can move.
Try to set your scene Rect with big values at initialization and dont call sceneRect in mouse event
Re: QGrapghicsView updating
You 're great!
I will try it right away!
Thank you, I lost 1 or 2 days just for that :-)