Take the 2-minute tour ×

I'm using Qt (Mac, version 4.7) to rendering a rather large scene (map data from Open Street Maps) with QGraphicsView and QGraphicsScene. Everything works great until I try to set the Z value for the items in the scene. I've tried two separate approaches to do this. In one, I just do:

QGraphicsPathItem *item = scene->addPath(path, pen);

and the other I create my own QGraphicsItem subclass, but get the exact same problem.

The cause of the slow down appears to be on the Qt side of things. It takes a very long time for the scene to generate once I set the z-value (it takes a few minutes before anything displays, and I get the spinning beach ball of death), but once it's generated, the speed is back to normal. Additionally, when I try to close the application it hangs for a few minutes before closing. I don't see any of these issues if I leave the z-value alone, and I've added debugging code to verify it's not occurring in my own code.

Unfortunately, I need to set the z-value in order to render streets correctly (e.g. outlines around roads, make highways a higher order than through streets, etc.).

Any help is greatly appreciated!

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You may try setting bspTreeDepth to a fixed value. It controls how an item in the scene is located. Changing the depth with a large number of existing items can be very costly.

Another candidate for optimization is itemIndexMethod. Setting it to noIndex may actually increase the performance.

share|improve this answer
The itemIndexMethod worked like a charm. I tried several values for bspTreeDepth without much luck. Thank you! –  Abe Schneider Dec 2 '11 at 17:03
add comment

Your Answer


