I learn Qt
and I want to download a XML file from the Internet.
The QUrl
is depending on further values value1 and value2; example:
http://www.example.org/path/the_xml_file.xml?value1=1&value2=2
Here I set the QString
destination_XML_URL
void AClass::setUrlString(quint32 t_value1, quint32 t_value2) {
destination_XML_URL = QString("http://www.anyweb.com/path/the_xml_file.xml?value1=%1&value2=%2").arg(t_value1).arg(t_value2);
}
Then I request that location with a QUrl
in a method:
QNetworkAccessManager url_network_access_manager;
//..;
setTarget(12, 34);
QUrl xml_Url(destination_XML_URL);
QNetworkRequest request(xml_Url);
QNetworkReply url_network_reply = url_network_access_manager.get(request);
Finally connecting the connect:
connect(&url_network_access_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slot_disconnect2Net(QNetworkReply*)));
Then the slot, after retrieving the xml file from web:
void AClass::slot_disconnect2Net(QNetworkReply *data) {
qint64 t_size1 = data->size();
int error_code = data->error();
switch(error_code) {
case 0:
transform_Raw_2_XML(data);
break;
case 3:
break;
case 301:
break;
default:
QMessageBox::critical(this, "AClass::disconnect2Net()", QString("Connection error %1:\n %2").arg(error_code).arg(data->errorString()), QMessageBox::Ok);
}
}
But I get error_code 3:
http://doc.qt.io/qt-4.8/qnetworkreply.html#NetworkError-enum
"QNetworkReply::HostNotFoundError = 3 : the remote host name was not found (invalid hostname)"
Any ideas?
Is it possible, that your connection is behind a proxy?