⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

Best way to transfer data between two threads ?

  • Hi,

    I have a main GUI thread and a separate thread for network connectivity and reading data from TCP Socket.

    The data read from the TCPSocket is to be sent to the main GUI thread for further processing. What is the best way to achieve this ?

    Should I use a shared buffer or a queued signal-slot connection is optimal ?
    (The TCPSocket data are expected to come pretty frequently.)


  • Moderators


    You don't need a separate thread for networking.

    Just use the QTcpSocket's asynchronous API: connect the readyRead() signal to a slot that reads and processes the data. Your GUI will remain responsive.

Log in to reply