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. Should I put connect to another thread?
Qt 6.11 is out! See what's new in the release blog

Should I put connect to another thread?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 582 Views
  • 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 Offline
    M Offline
    Mr Pang
    wrote on last edited by
    #1

    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?

    jsulmJ 1 Reply Last reply
    0
    • M Mr Pang

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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
      2
      • jsulmJ jsulm

        @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.

        M Offline
        M Offline
        Mr Pang
        wrote on last edited by
        #3

        @jsulm
        Great. Thanks

        1 Reply Last reply
        0

        • Login

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