I have overloaded the paintEvent() function and I am calling it through repaint() when required. But, paintEvent() is also getting called when we refresh/update the window(by minimizing, maximizing the window,etc......) .How to avoid this?