How to suppress user defined events in processEvents()
We've got some problems with widget repainting and user defined events generated by the underlaying process.
That's the situation:
- Some event handling causes to change the appereance of a dialog (includeing call to update()). This will get visible during a subsequent event processing of the corresponding painting event.
- Some thread of the underlaying process is posting application specific events (of type QEvent::User) to the GUI thread. This forces the main thread to start a more or less expensive handling.
Unfortunately, the application events may delay the re-painting if they are posted just before the update() call.
To re-draw that widget as soon as possible I'm calling processEvents() during the event handler routine. But, how can I suppress the delivery of the application events along with the user input events (as defined by QEventLoop::ExcludeUserInputEvents) when calling processEvents() :confused:
Re: How to suppress user defined events in processEvents()
You can always subclass QCoreApplication::notify() or QCoreApplication::event() (or apply an event filter on the application object) and do the filtering there.
Re: How to suppress user defined events in processEvents()
Quote:
Originally Posted by
wysota
You can always subclass QCoreApplication::notify() or QCoreApplication::event() (or apply an event filter on the application object) and do the filtering there.
Well. But filtering events this way will consume all events. However, I want to keep the user defined ones in the event queue for later processing (in the main event loop).
Re: How to suppress user defined events in processEvents()
You can't put your own custom events "on hold" if processEvents() doesn't support that. You can only discard an event by filtering it out.
Re: How to suppress user defined events in processEvents()
Quote:
Originally Posted by
wysota
You can't put your own custom events "on hold" if processEvents() doesn't support that. You can only discard an event by filtering it out.
That's a pity :(
If there is somebody from the developer team is watching this thread ...
Wouldn't it be nice to have a new ProcessEventsFlag ExcludeUserDefinedEvents, which suppresses external influences in a way like ExcludeUserInputEvents and ExcludeSocketNotifiers do?
This supports a more strict separation of GUI related and process/application related parts even in an event driven design.
Re: How to suppress user defined events in processEvents()
http://www.trolltech.com/developer/tasktracker
BTW. I believe it is still doable using QCoreApplication::notify(), but it might not be worth the effort.