hi
i am doing only one operation inside paintEvent(QPainter::drawPixmap()) ,is it necessary to use save() and restore() .
Printable View
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.
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.