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

    Thanks


  • Moderators

    Hi,

    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.