QGraphicsScene population SLOW on Windows but not any other platform?
gyrovorbis last edited by
We are developing a 2D, tile-based level editor for a game that we are developing. We've opted to use the QGrahpicsScene/QGraphicsItem paradigm rather than a custom OpenGL widget, because of the functionality that it provides for things like selection...
A "map" in our game is 4 layers of 200x200 tiles, each 32x32 pixels wide. So that's a buttload of QGraphicsItems to be adding to the scene. This seems to be no problem on my Macbook Pro and even a shitty old Kubuntu desktop of mine. But for some reason, EVERY WINDOWS MACHINE, including a brand new i7 processor that I have at work takes an unforgivable amount of time to do this. Something in the range of 20+ seconds of complete unresponsiveness...
I have tried adding every item separately in a single loop (each location adds 4 QGraphicsItems at different zcoords), I've tried adding them separately in separate loops (each layer is added, then the next layer, etc), and I've tried adding each layer to its own "layer parent" item, adding only the 4 top-level parents to the scene... All of these methods seem to make very little difference on the horrible population performance.
I have also tried setting the depth of the BSP manually. Didn't make a difference. I've tried populating the scene before it is being displayed in a view (just in case some redraw signals/slots were firing), still no difference.
And as I've said, it seems to ONLY be a problem on Windows. But it's a HUGE problem.
Also: we have no performance issues ONCE THEY HAVE BEEN ADDED. It is just the initial scene population time.
Does anybody have any ideas or experience with QGraphicsScenes containing buttloads of items?
Asperamanca last edited by
I have no definitive answer, but a few questions that might shed some light on the issue:
Have you tried turning off the BSP tree altogether using setItemIndexMethod(QGraphicsScene::NoIndex)?
Is the scene invisible at the time it is populated?
Is the scene attached to the view at the time it is populated?
Have you tried creating the items, but NOT adding them to the scene? (Question is: Is the constructor of the items slow, or the addItem call?)
Does the "40000 chips" Qt example run slowly?