PDA

View Full Version : Smooth zooming with mouse pointer as center



gaganbm
27th June 2013, 11:35
Hi,

No matter what I do, the zoom in my GraphicsView is always happening in the same manner, which doesn't take my mouse pointer into consideration.

Basically I want the zoom to happen like google maps. And I did try with the approach provided here (http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_ Zooming).

As a standalone GraphicsView it works perfectly. But in my project, I have a graphWidget (a custom class inheriting QGraphicsView) and a tabWidget separated by a splitter. (designed in UI forms). And in the code, I initialize the graphicsView.

I added the same wheelEvent implementation to my graphicsView class, but it doesnt show any difference. It always zooms in the same way, without caring about mouse position.

Any help ?

Let me know if more details are needed.

swaczin
27th June 2013, 11:57
Hi,

have you tried to set the QGraphicsView::transformationAnchor to QGraphicsView::AnchorUnderMouse?

gaganbm
27th June 2013, 12:02
yes of course. As I said, it works if I test with the example in the link I posted. But in my project, the same code doesnt work. Don't understand why.