[Interest] Animating viewable rect of QGraphicsView

Patrick Stinson patrickkidd at gmail.com
Mon Feb 25 19:53:17 CET 2019

How can I animate the viewable scene rect of a QGraphicsView using screen coordinates? This means animating both center pos and scale. This is similar to Google Earth where the map scrolls and zooms smoothly from one point to another. I have searched for an answer for this several times in the last couple of years with little success.

The use case is that I use QGraphicsView::fitInView to show the bounding rect of all visible items. Then some items are hidden and I want to animate zooming/scrolling to fit the new bounding rect of all the items.

Simply setting up one animation to periodically call QGraphicsView::centerOn() and another to call QGraphicsView::scale() doesn't work because calling one displaces the values of the other as the interpolation progresses.

Thoughts? This seems like a pretty essential use case for QGraphicsView.


More information about the Interest mailing list