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

Thiago Macieira thiago.macieira at intel.com
Tue Aug 13 19:50:49 CEST 2013

On quarta-feira, 14 de agosto de 2013 00:35:47, Richard Turner wrote:
> OK. Now the problem is, when I use downloadUrl1(result from fromEncoded)
> to make a QNetworkRequest (HTTP GET), I always detect an error: Protocol
> "" is unknown.
> When I switch to use downloadUrl2, all is good.

That was expected. Look at what your URL was:


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 

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.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130813/a12345ce/attachment.sig>

More information about the Interest mailing list