QNetworkAccessManager *man = new QNetworkAccessManager(this);
QUrl downloadUrl = QUrl::fromEncoded(downloadUrlStr.toAscii()); qDebug() << downloadUrl.toString(); QNetworkRequest req(downloadUrl); req.setAttribute(QNetworkRequest::User, id); QNetworkReply *finalReply = nam->get(req); connect(finalReply, SIGNAL(finished()), this, SLOT(dataFetchFinished()));
I have the above code in my Qt 4.8.4 application, but in the dataFetchFinished() slot I keep detecting the error: Protocol "" is unknown
The debug output is: "http://192.168.1.1/servlet/com.roving.report.view.excel.ExcelReportServlet?file=661&columns=0&srcType=defineBean&width=0&height=0&reportParamsId=100583&cachedId=662&t_i_m_e=1376086878417&pageStyle=0"
Any help is much appreciated!
|
FWIW The QString downloadUrlStr is http%3A%2F%2F192.168.1.1%2Fservlet%2Fcom.roving.report.view.excel.ExcelReportSe rvlet%3Ffile%3D661%26columns%3D0%26srcType%3DdefineBean%26width%3D0%26height%3D0% 26reportParamsId%3D100583%26cachedId%3D662%26t_i_m_e%3D1376086878417&pageStyle=0 – Turner Aug 9 '13 at 22:46
|
||
|
QUrl::fromPercentEncoding should work. Check out Qt Docs or Sources to see difference between these two. – elmigranto Aug 9 '13 at 23:48
|
||
|
@elmigranto It works like charm! But I'm still trying to figure out the underlying difference between these two static methods – Turner Aug 10 '13 at 16:45
|
||
|
Well, fromEncoded is basically QUrl(QString::fromUtf8(QByteArray)); while fromPercentEncoding actually decodes percent encoding. – elmigranto Aug 12 '13 at 6:43
|