Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Does connection of SLOT and SIGNAL from different threads must be made in the sender or in the reciever thread ?
Forum Updated to NodeBB v4.3 + New Features

Does connection of SLOT and SIGNAL from different threads must be made in the sender or in the reciever thread ?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 742 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aabc
    wrote on last edited by A Former User
    #1

    Does connection of SLOT and SIGNAL from different threads must be made in the sender or in the reciever thread ?
    Also, Does the connection and disconnection must be made in the same thread ?

    JKSHJ 1 Reply Last reply
    0
    • A aabc

      Does connection of SLOT and SIGNAL from different threads must be made in the sender or in the reciever thread ?
      Also, Does the connection and disconnection must be made in the same thread ?

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      @aabc said:

      Does connection of SLOT and SIGNAL from different threads must be made in the sender or in the reciever thread ?
      Also, Does the connection and disconnection must be made in the same thread ?

      It doesn't matter, because connect() and disconnect() are thread-safe.

      Just make sure your connection uses Qt::AutoConnection or Qt::QueuedConnection, so that the slot runs in the receiver's thread.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mcosta
        wrote on last edited by
        #3

        Hi,

        from technical point of view @JKSH is right.
        From design point of view senders shouldn't know about objects connected to their signals: a signal is simply an indication of something is changed in the sender internal state and then is incorrect make the connection in the sender code. (doing this the sender will be tightly coupled with the receiver)

        SIGNALS/SLOTS are designed to avoid (or reduce as much as possible) the coupling from senders and receivers

        Once your problem is solved don't forget to:

        • Mark the thread as SOLVED using the Topic Tool menu
        • Vote up the answer(s) that helped you to solve the issue

        You can embed images using (http://imgur.com/) or (http://postimage.org/)

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved