TcpSocket and QTextStream does not print first line of data
I have the following function:
Code:
void Rsh::receiveMessage() {
if( !tcpSocket->canReadLine() )
{
return;
}
while( tcpSocket->canReadLine() ){
responseLine = tcpSocket->readLine();
response.append(responseLine);
}
ui.ResultsTextEdit->append(tr("%1").arg(response));
}
This works to pull data from the connection, however the first complete line of text is always missing...
any ideas?
Re: TcpSocket and QTextStream does not print first line of data
Re: TcpSocket and QTextStream does not print first line of data
Re: TcpSocket and QTextStream does not print first line of data
Quote:
Originally Posted by
nbkhwjm
Thats the only one....
Could you elaborate? You create QTextStream instance and never use it and most likely that's what eats your first line.
Re: TcpSocket and QTextStream does not print first line of data
You are correct... The first line was in the "in" buffer.... while i was only printing the "response".
This seems to work fine...
Thanks for the pointer.
Code:
void Rsh::receiveMessage() {
if( !tcpSocket->canReadLine() )
{
return;
}
while( tcpSocket->canReadLine() ){
responseLine = in.readAll();
response.append(responseLine);
}
ui.ResultsTextEdit->append(response);
}