[QGraphicsView] centerOn() with smooth scrolling
Is there any way to get something similar to the function centerOn() but with smooth scrolling?
I have the scene (-640, -780, 1280, 1560) and one item (football player) that is following the cursor all the time.
I want the view to display this item just as centerOn() but without jumps when scrolling. It's because centerOn() uses int instead of qreal. I have tried many things, for example: setSceneRect( sceneRect().translated( diff.x, diff.y ) ) where diff is difference between item position and mapToScene( geometry().center() ) but it doesn't work as expected.
Re: [QGraphicsView] centerOn() with smooth scrolling
Quote:
Originally Posted by
And_re
It's because centerOn() uses int instead of qreal.
Not according to the documentation:
http://doc.qt.nokia.com/4.6/qgraphicsview.html#centerOn
Re: [QGraphicsView] centerOn() with smooth scrolling
But I talk about implementation of this function in sources.
And there is something like that:
horizontalScrollBar()->setValue(int(viewPoint.x() - width / 2.0));
verticalScrollBar()->setValue(int(viewPoint.y() - height / 2.0));
Re: [QGraphicsView] centerOn() with smooth scrolling
use translate() rather than centreOn().