Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I implement Google Maps-like tile scrolling in Qt?

I'm using Qt/C++ and trying to draw a large and complex QGraphicsScene. Once I add a lot of objects, panning and zooming become unpleasantly slow. (No surprise here, of course). I've played with device coordinate caching (helps with panning to a point) and minimal viewport updates and so on, but eventually there's just too many objects. What I'd like to do is draw the items asynchronously from controlling the UI somehow. In other words, just like Google Maps does, I want to pan and zoom and let drawing catch up as fast as it's able, but to be able to pan again before the items finish drawing.

One method I'm trying is to create two QGraphicsScenes. One has the actual objects but is not attached to a QGraphicsView. The other QGraphicsScene is connected to the QGraphicsView, but it just has some tiled QPixmaps that are sized to cover the screen. The plan is to use spare CPU cycles to update any tile pixmap that needs it. This seems like it will give me the necessary control over rendering (so I don't have to block while re-rendering the entire visible scene). Thoughts? Has anyone implemented this?

like image 772
Scott Stafford Avatar asked Feb 10 '10 18:02

Scott Stafford


1 Answers

Take a look here: Generating content in threads.

It sounds like this is similar to what you are trying to do. Tile mechanisms are very common ways to load in large amounts of data. Other than the link posted, I have not seen a simple example using QGraphicsView.

40000 Chips also shows some things about managing large amounts of data.

like image 108
Adam W Avatar answered Sep 18 '22 13:09

Adam W