encode in url.addQueryItem
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!
Re: encode in url.addQueryItem
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:
Code:
url.
addEncodedQueryItem("another",
QUrl::toPercentEncoding("abc+bcd"));