PDA

View Full Version : How to suppress user defined events in processEvents()



Artschi
4th July 2007, 16:54
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:

wysota
4th July 2007, 17:01
You can always subclass QCoreApplication::notify() or QCoreApplication::event() (or apply an event filter on the application object) and do the filtering there.

Artschi
4th July 2007, 18:11
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).

wysota
5th July 2007, 00:09
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.

Artschi
5th July 2007, 11:12
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.

wysota
5th July 2007, 11:17
http://www.trolltech.com/developer/tasktracker

BTW. I believe it is still doable using QCoreApplication::notify(), but it might not be worth the effort.