The project I'm working on uses a QGraphicsView, with a QGraphicsScene, and thousands (10K to >100K worst case) QGraphicsItems. The scene is interactive allowing for selection and drag and drop of some of the items. After much refinement, through displaying only what absolutely needed to be displayed and creating QGraphicsItems only when absolutely needed, I was able to bring performance to an acceptable level despite having a large number of QGraphicsItems displayed in the scene at one time.
Then, I switched from Qt 4.5.2 to Qt 4.6.1. After making the necessary updates of removing obsoleted member functions and replacing them with the updated ones, I noticed that the redraw performance was significantly slower.
For example, when selecting an object, using Qt 4.5.2 it would change to its selection color (red) basically immediately. Now, after changing to Qt 4.6.1, it takes anywhere from 1-2 seconds. Even worse, when drawing a QRubberband for doing area selection, using Qt 4.5.2, the QRubberband would track fairly well with the mouse. Now, with Qt 4.6.1, the QRubberband takes about 2-3 seconds to first display the rubber band, and then only after I stop moving the mouse for 1-2 seconds does it display the updated rectangle.
Just to provide some more information. I have tried removing the graphical items in the scene. There are essentially two types of items in my scene. One type is placed regularly around the scene (QGraphicsRectItem), and when I draw just these performance is okay. The other type is about 10x smaller (also QGraphicsRectItem), and they are packed closer together, but scattered in different areas around the scene. When drawing just the smaller item type, then graphical performance suffers. What is peculiar is that for one case, the number of large items is about 6K and the number of small items is 1.5K. This is odd, because it seems like it is not the number of items, but rather that the smaller items are treated differently by Qt. To narrow it down and eliminate my paint function, I also commented out my custom paint code so it would only call 'drawRect' and still saw a significant performance hit.
Has anyone else seen a similar issue with their move to 4.6? If so, what did you do to fix it?
Thanks very much!
Bookmarks