View Full Version : encode in url.addQueryItem

29th March 2011, 06:18
In my project I want to visit an url with some arguments and catch the return parameters. I take the following codes for test.
QUrl url = QString("http://localhost/test")
url.addQueryItem("test", QString("abc+bcd"));

But the arguments my server received is "abc bcd". Plus is replaced by " ". I don't know how to fix it. Simply modifying the '+' character by "%2B" doesn't work.
Who could help me? thanks very much!

29th March 2011, 09:24
Qt should be encoding the literal '+' as %2B on your behalf. There is a bug that has been (I think incorrectly) closed as invalid: http://bugreports.qt.nokia.com/browse/QTBUG-10146

You can work around it with this:

url.addEncodedQueryItem("another", QUrl::toPercentEncoding("abc+bcd"));