views:

390

answers:

1

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?

+1  A: 

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.

Adam W
I have seen "40000 Chips" - my understanding of that example is that it does a nice "Level of Detail" implementation technique, where it only has one item in the QGraphicsScene for each chip, but the paint() of the chip draws additional detail if the zoom is above various thresholds.The link you offered seems very relevant. I'll try it out in detail as soon as I get a chance... Thanks!
Scott Stafford