I have a thread that handles different connections from different computers.

I want to know when one of those connections (telnet) has been closed. I am trying to use the disconnect signal, but the method clientDisconnected is never called.

Qt Code:
  1. # include <QTcpSocket>
  2.  
  3. # include <iostream>
  4. # include "client.h"
  5. # include "server.h"
  6. using namespace std;
  7.  
  8. Client :: Client(int socketDescriptor, Server *server, QObject *parent) : QThread(parent)
  9. {
  10. this->socketDescriptor = socketDescriptor;
  11. this->server = server;
  12. chattingWith = new QString();
  13. connect(this, SIGNAL(finished()), this, SLOT(finished()));
  14. }
  15.  
  16.  
  17. void Client :: run()
  18. {
  19. cout << "void Client :: run()\n";
  20. tcpSocket = new QTcpSocket();
  21. if(!tcpSocket->setSocketDescriptor(socketDescriptor))
  22. {
  23. cout << "Error - tcpSocket descriptor\n";
  24. return;
  25. }
  26. connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readData()));
  27. connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
  28. exec();
  29. }
  30.  
  31.  
  32. void Client :: readData()
  33. {
  34. cout << "void Client :: readData()\n";
  35. server->addClient("12345", this);
  36. }
  37.  
  38.  
  39. void Client :: clientDisconnected()
  40. {
  41. cout << "void Client :: clientDisconnected()\n";
  42. }
  43.  
  44. void Client :: finished()
  45. {
  46. cout << "The thread has finished\n";
  47. }
To copy to clipboard, switch view to plain text mode 

Why ? What is wrong ?