jcbikeski
22nd July 2011, 17:59
I'm using Qt 4.6.
I have an application that displays plots of data that require several hundred thousand draw operations on a painter. On a fast computer this can take a few seconds to do. Dragging the mouse to resize causes multiple repaint events which can't be handled well at these drawing speeds.
I've read there is no way to really know when the resize is really over so the best I've heard from others is to restart timer on resize for maybe 0.1 seconds or so after every resize event then repaint when the timer finally has a chance to expire without another resize. So my first question is whether anyone has found a more elegant solution than this.
Some suggest painting to a pixmap outside the paint event handler then repainting the pixmap. I also need to have this widget output to high resolution printer or vector graphic file (like encap. postscript) so I don't know if this pixmap strategy works well or maybe I alter this behavior if I detect the repaint was for printing instead of the screen. Anyway I'm curious if others have had similar needs and found good solutions.
For those that have used the timer approach, I'm wondering if you can share any code snippets on your particular strategy including whether you inhibit paint from event being called until the timer or just have the paint handler ingore the request until you see a flag from the timer routine saying resize is done.
Also, does anyone know of any document that shows clearly the order and reasons resize or repaint gets called so I can be sure I'm addressing all situations related to these events.
Thanks for any help
John
I have an application that displays plots of data that require several hundred thousand draw operations on a painter. On a fast computer this can take a few seconds to do. Dragging the mouse to resize causes multiple repaint events which can't be handled well at these drawing speeds.
I've read there is no way to really know when the resize is really over so the best I've heard from others is to restart timer on resize for maybe 0.1 seconds or so after every resize event then repaint when the timer finally has a chance to expire without another resize. So my first question is whether anyone has found a more elegant solution than this.
Some suggest painting to a pixmap outside the paint event handler then repainting the pixmap. I also need to have this widget output to high resolution printer or vector graphic file (like encap. postscript) so I don't know if this pixmap strategy works well or maybe I alter this behavior if I detect the repaint was for printing instead of the screen. Anyway I'm curious if others have had similar needs and found good solutions.
For those that have used the timer approach, I'm wondering if you can share any code snippets on your particular strategy including whether you inhibit paint from event being called until the timer or just have the paint handler ingore the request until you see a flag from the timer routine saying resize is done.
Also, does anyone know of any document that shows clearly the order and reasons resize or repaint gets called so I can be sure I'm addressing all situations related to these events.
Thanks for any help
John