I have a custom QGraphicsItem which has a QPainterPath as member.
As the mouse is dragged, the movement is traced onto this path. The paint() method in the QGrahicsItem draws the whole path everytime a new point is added to the path.

The purpose of implementing this is, the whole path is drawn to an image when the mouse is released (The image needs to be free for other drawing as long as possible, so can't directly draw on it).

The issue here is, as the path gets longer, the updating of graphics on QGraphicsScene gets visibly slower (while mouse is dragged for a long time).

Is there a way to optimize and speed up the paint() method in this case, while keeping the path info which needs to be directly drawn to an image?