I have a QGraphicsScene with about 1000 QGraphicsItems, which are actually physics items. Each frame they advance, check for collisions, and resolve those collisions, among other things. I would really like to have the physics multithreaded.
It is my understanding that the QGraphics classes are not thread-safe. Meaning, they can only be called from the main thread. Does this force me to send the final item properties (x, y, rotation) each frame to the main thread using a signal/slot mechanism, and then use a main thread method to actually update the QGraphicsItems? Or is there an easier way to do this?
What follows is just a hypothesis: Could I use QtConcurrent to run a method on my list of QGraphicsItems? If I use a QMutex in my QGraphicsItem paint method and a QMutex in my physics method (that will change properties of my QGraphicsItem), would this guarantee that only one thread is reading/writing each QGraphicsItem at any one moment in time?