Solved Two identical signals in one class [QTcpSocket]
-
Hi all,
I have implemented two TCP clients in one class. I want to use
connect(socket1, SIGNAL(readyRead()),this, SLOT(readyRead()));
and
connect(socket2, SIGNAL(readyRead()),this, SLOT(readyRead()));
Is it possible to have two different signals so that I have a seperate readyRead() function for both sockets?
Thanks!
-
It is. You can either use QObject::sender() to retrieve the sender object or better use the new signal/slot syntax with a lambda and pass the socket pointer to the slot.
-
It is. You can either use QObject::sender() to retrieve the sender object or better use the new signal/slot syntax with a lambda and pass the socket pointer to the slot.
-
Thank you, the new signal/slot syntax with a lambda works fine, e.g.:
connect(socket1, &QTcpSocket::readyRead, [=]( ) { resultTcpSD = socketSD -> readAll(); });