Hi,
I have seen this question raised on these forums and I feel I have done everything correctly so I was wondering if someone could help point out my fault.
So I have the following code that behaves as expected when there is a connection to the outside world, however when an error occurs errorString tells me there was an "unknown error". Why?
void myClass::checkInternetConnection()
{
qDebug() << "checking internet connection";
QNetworkAccessManager* am = new QNetworkAccessManager;
connect(am, SIGNAL(finished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply*)));
am
->get
(QNetworkRequest
(QUrl("http://google.com")));
}
void myClass::checkInternetConnection()
{
qDebug() << "checking internet connection";
QNetworkAccessManager* am = new QNetworkAccessManager;
connect(am, SIGNAL(finished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply*)));
am->get(QNetworkRequest(QUrl("http://google.com")));
}
To copy to clipboard, switch view to plain text mode
the slot, I would expect this to always be a QNetwokReply::NoError condition.
void onFinished(QNetworkReply* r)
{
qDebug() << "Finished checking internet connection" << r->errorString();
emit connectionVaild();
}
void onFinished(QNetworkReply* r)
{
qDebug() << "Finished checking internet connection" << r->errorString();
emit connectionVaild();
}
To copy to clipboard, switch view to plain text mode
All the best
Bookmarks