I am working on a server-client application,i spent in a lot of hours to understand why the application is terminated in an unusual way.Well,the problem was that,firstly connect methods, that now are defined in run method,were defined in the thread's constructor.Now application is not terminated.
The problem is these warnings:
QSocketNotifier: Multiple socket notifiers for same socket 1172 and type Read:
Can you explain me why this warning diplayed?
without this command:tcpSocket->setSocketDescriptor(fd);
tcpsocket's socketdescriptor in the thread constructor is -1 .

QObject::connect: Cannot queue arguments of type 'Qt::GlobalColor'
(Make sure 'Qt::GlobalColor' is registered using qRegisterMetaType().)

Can you give an example:i have read the documentation and i tried
qRegisterMetaType<Qt::GlobalColor>(Qt::GlobalColor ); but this command gave errors at compilation time.

Qt Code:
  1. void MainServer::incom() {
  2.  
  3. QTcpSocket * mySocket = mainServer.nextPendingConnection();
  4.  
  5. ServerThread * serverThread = new ServerThread(mySocket->socketDescriptor(), this);
  6. // connect(serverThread, SIGNAL(finished()), ServerThread, SLOT(deleteLater()));
  7. serverThread->start();
  8. }
  9.  
  10.  
  11.  
  12. /* thread's constructor */
  13. ServerThread::ServerThread(int socketDescriptor,QObject *parent)
  14. : QThread(parent)
  15. {
  16. fd=socketDescriptor;
  17. mySocket = new QTcpSocket();
  18. tcpSocket->setSocketDescriptor(fd);//according to Fortuneserverthread example
  19.  
  20.  
  21.  
  22.  
  23.  
  24. }
  25. //run method is protected
  26. void ServerThread::run()
  27. {
  28. connect(mySocket, SIGNAL(readyRead()), this, SLOT(dataRead()));
  29. connect(this, SIGNAL(writeLog(QString, int, int, int, Qt::GlobalColor)), (mServer *)(this->parent()), SLOT(writeLog(const QString&, const int&, const int&, const int&, const Qt::GlobalColor&)));
  30. exec();
  31. }
  32.  
  33.  
  34. void FortuneServerThread::dataRead()
  35. {
  36.  
  37.  
  38. ....//read data from socket and emit a signal for example:
  39. ... emit writeLog(str.append("User is in System"));
  40.  
  41. quit();
  42.  
  43. }
To copy to clipboard, switch view to plain text mode 

@