PDA

View Full Version : post method problem



DmitryNik
7th November 2011, 20:15
Hello.

I got a small problem with a post method using QNetworkAccessManager. After sending the data to http-server, I would like to read a response from the server. And here is the problem. After the first response from the server. I can't send any data to the server anymore. Here is the code:



void Client::SendData(QIODevice *data)
{
this->reply = this->objectQNetworkAccessManager->post(this->objectQNetworkRequest,
data);
connect(this->reply, SIGNAL(finished()),
this, SLOT(readData()));
}

void Client::readData()
{
if(this->reply->error() == QNetworkReply::NoError)
{
qDebug() << "data send";
qDebug() << this->networkReply->readAll();
}
else
{
qDebug() << "error";
}
this->reply->deleteLater();
}


If I don't try to read any data from QNetworkReply everything works fine...
What's wrong with the code above?
Thank you for answers beforehand.

Added after 4 minutes:

Sorry for disturbing... I found the answer.

connect(this->reply, SIGNAL(readChannelFinished()),
this->reply, SLOT(deleteLater()));