hi everyone, i have the "if" statement below. the purpose of this 'if' statement is to check if the string 'LoginDetail@#%$^*&_FhDKooKSE' is contained in the QByteArray 'readAll', if the condition is true the 'else' part of the 'if' statement is executed otherwise whatever is in the QByteArray is displayed on screen. the else part works fine but the 'false' condition displays empty strings even though there is something to display in the QByteArray. I think this is because the statement 'socket.readAll()' is executed twice, first in the condition of the 'if' statement secondly just below the 'if' statement.
void Client::readSocket()
{
if(!socket->readAll().contains("LoginDetail@#%$^*&_FhDKooKSE"))
qDebug() << socket->readAll() <<endl;
else
qDebug() << "Login window is opened";
}
void Client::readSocket()
{
if(!socket->readAll().contains("LoginDetail@#%$^*&_FhDKooKSE"))
qDebug() << socket->readAll() <<endl;
else
qDebug() << "Login window is opened";
}
To copy to clipboard, switch view to plain text mode
how can i fix this.
Bookmarks