how to stop repainting of a widget when it's resized
i am making a software in which paint event painting a widget as per my need but the problem
is that when i re-size my application window it painted it again so please tell me the way
to stop paint event from painting my widget on resi开发者_StackOverflowzing the main window.
my file are:
v_lab.h(http://qt.pastebin.com/tjHAWkPH)
v_lab.cpp(http://qt.pastebin.com/teJDmMmt) main.cpp(http://qt.pastebin.com/gsUytaCN)Thanks
No, you do want to redraw every time the main window resizes. But your design is somewhat weird, as you are creating random stuff inside the paintEvent
function. You should create that stuff elsewhere as needed, store that stuff in a QPixmap or something and just redraw the image in the paintEvent
function.
In other words, paintEvent
should only repaint the view in its current state and should not contain anything that changes the state.
精彩评论