hi
i am doing only one operation inside paintEvent(QPainter::drawPixmap()) ,is it necessary to use save() and restore() .
hi
i am doing only one operation inside paintEvent(QPainter::drawPixmap()) ,is it necessary to use save() and restore() .
No, of course not, Qt guards the painter state itself before calling your code, so all the changes to the painter will be restored after the paint event of yours is left.
babu198649 (28th July 2008)
If i do a series of operations inside a paintEvent(pixmap painting,draw lines,e.t.c),then is it necessary to use save() and restore().
If you perform one operation at a time and require the same operation sometime later then save it and restore it later ...
You will instantiate a different QPainter object on the stack during every paintEvent() anyway so saving and restoring doesn't make sense unless you really need to get back to some earlier state. Drawing a line doesn't change the state of a QPainter object, but for example setting a pen before drawing the line does. QPainter docs contain a list of settings what are saved and restored.
J-P Nurmi
babu198649 (28th July 2008)
Bookmarks