Results 1 to 5 of 5

Thread: What's the relationship between signal/slot and event?

  1. #1
    Join Date
    Jan 2006
    Location
    Beijing
    Posts
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Smile What's the relationship between signal/slot and event?

    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!

  2. #2
    Join Date
    Jan 2006
    Posts
    32
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: What's the relationship between signal/slot and event?

    Quote Originally Posted by twosnowman
    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

  3. #3
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: What's the relationship between signal/slot and event?

    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.
    It's nice to be important but it's more important to be nice.

  4. #4
    Join Date
    Jan 2006
    Location
    Beijing
    Posts
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: What's the relationship between signal/slot and event?

    for the 3rd question,I 'm not clear about whether a signal is traslated to be an event and added to the event loop.

  5. #5
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: What's the relationship between signal/slot and event?

    Quote Originally Posted by twosnowman
    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.

Similar Threads

  1. Replies: 4
    Last Post: 19th February 2009, 12:10
  2. Custom event gets not propagated to the top level widget
    By nightghost in forum Qt Programming
    Replies: 0
    Last Post: 29th January 2009, 10:06
  3. Qt event queue overloading?
    By gct in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2008, 19:39
  4. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 22:55
  5. Replies: 4
    Last Post: 23rd January 2006, 17:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.