I'm new to Qt and currently learning to code with QTcpServer
and QTcpSocket
.
My code to process data is like
Myclass()
{
connect(&socket, &QTcpSocket::readyRead, this, &MyClass::processData);
}
void MyClass::processData()
{
/* Process the data which may be time-consuming */
}
Is it the correct way to use the signal like that? As I'm reading the documentation that in the same thread the slot is invoked immediately, which means if my processing work hasn't finished and new data comes, Qt will pause on the current work and enter the processData()
again. That is not exactly what I want to do, So should I QueueConnection
in the signal/slot connection?
Or could you please provide some good methods that I should adopt in this case?