PDA

View Full Version : Resize event on stretch?



kodiak
29th August 2008, 09:38
Hi,

The central widget of main window displays digital map image. On resize event map image needs to be repainted. Image generation consumes much time and cause unacceptable lags when main window or centarl widget is resizeing by stretching.

How to prevent resize events caused be stetching and fire one resize event when stretching is finished?

Thanks a lot!

wysota
29th August 2008, 09:46
You can't - your operating system controls that. But you can react to resize events in a smart way. When you receive a resize event start a timer that will fire after say... 1 second. If you see another resize event before it timeouts - restart the timer so that you have another second. Now for the best part - the timer should also set a flag that the widget is being resized and the timeout slot should reset that flag (and call update() on the widget). Then, in your paint event check if the flag is set. If it is - you know are during a resize. In that case don't regenerate the complex drawing, instead draw something simple like "please wait" text.

The outcome will be that your widget will be repainted one second after the resize is complete.

d_stranz
3rd November 2008, 23:51
Thanks, Wysota. I have the same problem, and thought about using a timer as you suggest. I couldn't figure out the right logic to make it work well. I'll implement your approach.