First I would like to say; I'm new to Qt, so this may be a simple question.
I'm trying to make a simple tcp server/client application, where the client can send a string to the server. My problem is that I want a list of connected clients, and if a client disconnect it should be remove from the list.
Any ideas on how to do that?
I tried the following:
The function to remove the client from the list
void Server
::removeClient(QString address
) {
for(int i = 0; i < clientList.size(); i++)
{
if(strcmp(clientList.at(i).toAscii(), address.toAscii()) == 0)
{
clientList.removeAt(i);
}
}
}
void Server::removeClient(QString address)
{
for(int i = 0; i < clientList.size(); i++)
{
if(strcmp(clientList.at(i).toAscii(), address.toAscii()) == 0)
{
clientList.removeAt(i);
}
}
}
To copy to clipboard, switch view to plain text mode
The signal-slot thing
connect(client, SIGNAL(disconnected()),
this,
SLOT(removeClient
(const QString &)));
connect(client, SIGNAL(disconnected()),
this, SLOT(removeClient(const QString &)));
To copy to clipboard, switch view to plain text mode
I don't know if I did it right since I'm new to the whole Qt thing. But I get this error:
Object::connect: No such slot Server::removeClient(QString &)
Bookmarks