PDA

View Full Version : What's the relationship between signal/slot and event?



twosnowman
10th January 2006, 08:23
I have several questions:
1).Signal/slot mechanism is synchronous or not? If it is,that means we should not let a slot do much work,otherwise the UI will be blocked for much time.
2).QEvent is asynchronous or not? For example ,if I call the update() function,the paintEvent() will be called, if it is asychronous,the UI will not be blocked.
3).Is there any relationship between signal/slot and event? Does Qt put the slots into event queue?
4).Qt document says that main event loop fetches native window system events and sends the translated events to QObjects,I want to know what's the relationship between main event loop and QWSServer?

Thanks!

Dusdan
10th January 2006, 10:46
I have several questions:
1).Signal/slot mechanism is synchronous or not? If it is,that means we should not let a slot do much work,otherwise the UI will be blocked for much time.
2).QEvent is asynchronous or not? For example ,if I call the update() function,the paintEvent() will be called, if it is asychronous,the UI will not be blocked.
3).Is there any relationship between signal/slot and event? Does Qt put the slots into event queue?
4).Qt document says that main event loop fetches native window system events and sends the translated events to QObjects,I want to know what's the relationship between main event loop and QWSServer?

Thanks!
1) it depends, you can call a slot in both synchronous and asynchronous mode;
2) same as before, it depends if you use sendEvent or postEvent. update is asynchronous
3) don't know exactly, I think there are two different queues for slots and events, but i'm not sure, I have to check the code.
4) I don't know, sorry

axeljaeger
10th January 2006, 10:52
1) Usually, slots are syncronous. Starting with Qt4, you can send signals across threads. If you execute a slot in another thread, you will get an asyncronous slot.
2) QEvents are syncronous but you can also deliver events in different slots. With Qt3, this was the only option to invoke something in a different thread.
3) With Qt4, you can tell Qt to post signals in the event queue using the 5th argument of the connect-method
4) QWSServer is only for Qt/Embedded where Qt is the window server itself.

twosnowman
11th January 2006, 06:24
for the 3rd question,I 'm not clear about whether a signal is traslated to be an event and added to the event loop.

Chicken Blood Machine
11th January 2006, 18:13
for the 3rd question,I 'm not clear about whether a signal is traslated to be an event and added to the event loop.

A signal is just a function call (lets ignore the asynchronous threading cases for now). It is generated in response to an event. For example, the QPushButton code will monitor for a mousebutton press and mousebutton release event within the same widget. In response to this, it will emit a clicked() signal. Most other signals are handled in a similar manner.