[Interest] Difference between QUrl::fromEncoded and QUrl::fromPercentEncoding ?

Richard Turner turner at yiran.org
Tue Aug 13 23:30:44 CEST 2013

On 2013/8/14 1:50, Thiago Macieira wrote:
> That was expected. Look at what your URL was:
> http%3A%2F%2F192.168.1.1%3A80%2Fservlet%2Fcom.mcdonalds.report.view.excel.ExcelReportServlet%3Ffile%3D4162%26columns%3D0%26srcType%3DdefineBean%26width%3D0%26height%3D0%26reportParamsId%3D101767%26cachedId%3D4163%26t_i_m_e%3D1376389959473&pageStyle=0
> Try pasting that in a browser and see what happens.
> The behaviour differs because QUrl::fromEncoded tries to interpret that as a
> URL. It has no scheme, so the entire thing is the path of the URL. Since it
> has no scheme, QNetworkAccessManager is correct in saying that "Protocol '' is
> unknown".
> QUrl::fromPercentEncoding does no interpretation. It simply decodes the
> percents. After that, you call the QUrl constructor on a different URL. Let me
> repeat: on a *different* URL.
Thank you very much Thiago!
Just one more question: could you elaborate on the idea that calling the 
QUrl constructor taking a QString is a big no-no in Qt 4 code, but not 
in Qt 5?


More information about the Interest mailing list