Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Deleting QGraphicsItem very slow
I am having problems deleting large numbers of QGraphicsItems. In one case, it takes about 30 seconds to create 100,000 QGraphicsItems put into 11 QGraphicsItemGroups, but it takes about 90 seconds to delete all these items. That is a long time for the user to wait unloading one document to then load a new one. Has anyone else noticed slowness deleting QGraphicsItems? Has anyone found a way around it?
Looking at the QGraphicsItem code, it might just be that all the checking in the destructor takes a longer time than setting up a simple QGraphicsItem. The solution I am contemplating is to delete all these items in a background thread.
PS. In another example, creating 350,000 QGraphicsItems in 16 QGraphicsItemGroups takes 1 minute 15 seconds, but deleting them takes over 16 minutes.
Doh! The QGraphicsItems were still part of a scene. I believed they were not. That explains the slowness.