Results 1 to 2 of 2

Thread: encode in url.addQueryItem

  1. #1
    Join Date
    Mar 2011
    Qt products
    MacOS X Windows

    Question 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!

  2. #2
    Join Date
    Mar 2009
    Brisbane, Australia
    Thanked 1,588 Times in 1,517 Posts
    Qt products
    Qt4 Qt5
    Unix/X11 Windows
    Wiki edits

    Default 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:

    You can work around it with this:
    Qt Code:
    1. url.addEncodedQueryItem("another", QUrl::toPercentEncoding("abc+bcd"));
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to ChrisW67 for this useful post:

    xyjian (29th March 2011)

Similar Threads

  1. Replies: 1
    Last Post: 29th March 2011, 10:12
  2. Encode/decode base 64 images
    By fitzy in forum Qt Programming
    Replies: 6
    Last Post: 28th October 2009, 18:38
  3. Encode html special characters
    By miraks in forum Qt Programming
    Replies: 4
    Last Post: 21st September 2009, 08:51
  4. QHttpResponseHeader encode & Save COOKIE value %20
    By patrik08 in forum Qt Programming
    Replies: 7
    Last Post: 8th April 2009, 22:22
  5. encode characters
    By smarinr in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2008, 06:46


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.