Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Should I put connect to another thread?

    General and Desktop
    2
    3
    85
    Loading More Posts
    • 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.
    • M
      Mr Pang last edited by

      I have a QSocketNotifier to watch one socket, and the slot function is in another thread.
      But now I call connect in my main thread

      connect(notifier, &QSocketNotifier::activated, tunFwd, &TunFwd::forwardTunPacket);
      

      The socket may have large packets to read, so activated signal will be emit frequently. Will this influence GUI main thread? Is it necessary to put the calling of connect to another thread?

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @Mr Pang last edited by

        @Mr-Pang It doesn't mater in which thread you call connect() as it just connects the signal to slot. If slot is executed in another thread then your UI thread should stay responsive.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply Reply Quote 2
        • M
          Mr Pang @jsulm last edited by

          @jsulm
          Great. Thanks

          1 Reply Last reply Reply Quote 0
          • First post
            Last post