Unlike the typical client/server situation, my chat application is both a client and a server. It is a server because it runs an instance of qtcpserver and it is a client, because you can make connections using qtcpsocket.

To have multiple connections i assumed you need multithreading although I have no experience with multithreading+ I'm new to QT.

Here is how I'm implementing the ability to establish a connection and then pass off that connection to its own thread.

Qt Code:
  1. // background info
  2. MSocket tcpSocket;
  3.  
  4. connect(&tcpSocket, SIGNAL(connected()),
  5. this, SLOT(connectionEstablished()));
  6.  
  7. tcpSocket.connectToHost(remoteIP, remotePort);
  8.  
  9. // end background.
  10.  
  11. void MChat::connectionEstablished() {
  12. chatOutput->append("<font color=green>Connection Established.</font>");
  13. MSocketThread* mSockThread = new MSocketThread(tcpSocket.socketDescriptor());
  14. connect(this, SIGNAL(sendText(QString&)),
  15. mSockThread, SIGNAL(sigSend(QString&)));
  16. connect(mSockThread, SIGNAL(relayIncomingText(QString&)),
  17. this, SLOT(outputText(QString&)));
  18. connect(mSockThread, SIGNAL(socketError()),
  19. this, SLOT(error()));
  20. connect(mSockThread, SIGNAL(finished()),
  21. mSockThread, SLOT(deleteLater()));
  22. mSockThread->start();
  23.  
  24. }
To copy to clipboard, switch view to plain text mode 


Here's how I'm implementing the MSocketThread

Qt Code:
  1. void MSocketThread::run() {
  2. MSocket mSocket;
  3. if ( !mSocket.setSocketDescriptor(socketDescriptor) ) {
  4. emit error(mSocket.error());
  5. return;
  6. }
  7. connect(&mSocket, SIGNAL(inboundText(QString&)),
  8. this, SIGNAL(relayIncomingText(QString&)));
  9. connect(this, SIGNAL(sigSend(QString&)),
  10. &mSocket, SLOT(send(QString&)));
  11. /*
  12.   connect(mSocket, SIGNAL(error(QAbstractSocket::SocketError)),
  13. this, SIGNAL(socketError()));
  14.   */
  15. mSocket.waitForDisconnected();
  16.  
  17.  
  18. }
To copy to clipboard, switch view to plain text mode 

Finally, here is the problem I'm encountering. When I try to send some chat, the console window displays this message:
QObject::connect: Cannot queue arguments of type 'QString&'
(Make sure 'QString&' is registed using qRegisterMetaType().)
And no chat gets displayed on the remote chat app. output.

Any tips, solutions, etc. are welcome as I am very new.