Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Best way to transfer data between two threads ?
gaganbm last edited by
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.)
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.