[Interest] how to get and purge events from queue?

Matthew Woehlke mwoehlke.floss at gmail.com
Mon Nov 23 19:25:17 CET 2020

On 05/11/2020 12.24, Jérôme Godbout wrote:
> Maybe you can add an event filter and remove some of the events if
> they are happening too close to each others. But I thing doing that
> logic into the event handler is a betetr idea, where you can either
> cumulate and delay execution of the behavior.
This. Separate your logic that decides an update is needed from the 
logic that actually does the update, and have the former *queue* (if not 
already queued) an event to do the latter.

I've used this technique on quite some occasions and IIUC Qt uses it 
internally when repainting widgets (n.b. QWidget::update).

If possible, also move some of that slow logic to a different thread...


More information about the Interest mailing list