views:

1863

answers:

5
+1  Q: 

Qt - Event handler

Does any one know how the event handler manages the posted events?

In my app i have two threads(1:guiThread and 2:computationThread). After an exception is thrown I call postEvent(..)to an existing dialog. The Qt-Event-Handler holds this one back until the dialog is closed.

A: 

Which threads library are you using (pthreads/qt threads/etc)? Which thread throws the exception, which thread was the dialog created in?

hazzen
+2  A: 

As mentionned in the Qt documentation about QCoreApplication::postEvent :

When control returns to the main event loop, all events that are stored in the queue will be sent using the notify() function.

...which explains why the Qt Event Handler holds the event until the dialog is closed.

If I understand correctly what you want to do, I would try using sendEvent.

Jérôme
+1  A: 

I'm guessing that the dialog you created is modal, which would mean that it is running its own event loop. No events posted to the general guiThread will be processed until all modal event loops are exited.

Alternately, if you need the dialog to both be modal and know about the event, you could post the event directly to the dialog. You'll need to figure out how to handle pointers in a shared manner, but if nothing complicated is going on, you might be able to use the QApplication::activeWindow() function.

Caleb Huitt - cjhuitt
A: 

Sorry my question is a bit cloudy. I will wirte it more exactly, if I have time left. I found a work around. But for me the problem is still interesting.

Thank you so far.

nutario
A: 

As others already wrote, I believe this behavior is caused by the fact that the dialog starts its own event loop.

If you use Qt4, you can try using queued signal/slot connections as an alternative to posting events.

agateau