timmu
24th August 2009, 13:03
I cannot figure out how to properly use slots/signals when QNetworkReply detects an error.
I'm trying to detect a website that doesn't exist and I'd like to see "host not found" error.
This is the main code:
QNetworkAccessManager* nam; QNetworkReply* reply;
nam = new QNetworkAccessManager(this);
QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotError(QNetworkReply::NetworkError)));
QUrl url; url.setUrl("http://www.random-wrong-website.com");
reply = nam->get(QNetworkRequest(url));
Here's my slot slotError()
void MyClass::slotError(QNetworkReply* reply)
{
//extract the error code from here
}
My questions:
1) Am I calling the slot correctly? I have a feeling I don't have the parameters right.
2) Do you know how to find out (in slotError()) what the error code was
Please help if you can. Thanks!!
I'm trying to detect a website that doesn't exist and I'd like to see "host not found" error.
This is the main code:
QNetworkAccessManager* nam; QNetworkReply* reply;
nam = new QNetworkAccessManager(this);
QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotError(QNetworkReply::NetworkError)));
QUrl url; url.setUrl("http://www.random-wrong-website.com");
reply = nam->get(QNetworkRequest(url));
Here's my slot slotError()
void MyClass::slotError(QNetworkReply* reply)
{
//extract the error code from here
}
My questions:
1) Am I calling the slot correctly? I have a feeling I don't have the parameters right.
2) Do you know how to find out (in slotError()) what the error code was
Please help if you can. Thanks!!