PDA

View Full Version : Repaint throttle anyone?



Micawber
17th December 2007, 15:35
Micawber here again with another problem :-(

I have an application that takes data very quickly. I want to display some of that data on 4 custom QWidgets. At any time, two of the QWidgets may be hidden and in that case the other two will grow to use the space from the hidden widgets.

I have another QThread that detects when a sample is ready and signals the main GUI loop that another sample is ready. This is really like drinking from a fire hose! I know that I don't want to display every sample, but I do want to display at the rate that the graphics environment can sustain and still be responsive to user inputs.

Right now I have code that calls repaint() on each of the widgets and it works, but it causes the system to be sluggish to user inputs. I would like to use update() but when I do that, I never see any updates to the screen because (I'm speculating) its off getting another sample and scheduling another update() before the engine has a chance to schedule and execute a paintEvent.

What I think I need is a way to sample the data stream, process it using update() and wait to get some sort of feedback that the area has been painted before going back to the fire hose for another sample. Is there a Qt API way to get notification that a paintEvent has been processed? I know that I can add a signal inside of the paintEvent, but I was wondering if there was another way.

Thanks,

-Mic

jacek
17th December 2007, 19:18
How do you exactly invoke update()?

Do you have to redraw everything with each repaint()? Maybe you can draw on a QPixmap and reuse it between repaints?

Also remember that you don't have to repaint faster than monitor's refresh rate. Even 25 Hz should be enough.