What is the difference between update and invalidate for QGraphicsScene?
opengpu last edited by
what is the difference between update and invalidate for QGraphicsScene?
and when to set the rect for them?
Asperamanca last edited by
Unless you directly paint into the scene (drawBackground, drawForeground) you'll rarely ever need to invalidate or update a specific rect. When you make changes to QGraphicsItems, and their boundingRects are correct, they take care of the required updates.
In some cases you might want to repaint the entire scene, which can be done using update().
Invalidate gives you more control about which layer of the scene you want to invalidate. A scene has a background layer (which you draw using drawBackground), a foreground layer (which you draw using drawForeground) and in between the item layer. As noted in the docs, calling invalidate on any layer but the background layer is equivalent to calling update.