Qt Code:
  1. QString q1 = QUrl::toPercentEncoding(username,"","~");
  2.  
  3. QUrlQuery params;
  4. params.addQueryItem("id", q1);
  5.  
  6. QString temp1 = params.query();
  7. //temp1 is just testing
To copy to clipboard, switch view to plain text mode 

When I debug, q1 value is properly encoded.
But for the params and temp1, some are not encoded?






Example:

1. Assigning username with value
Qt Code:
  1. "~`!@#$%^&*()_+-=;':"<>?,./"
To copy to clipboard, switch view to plain text mode 



2. Now q1 will be
Qt Code:
  1. "%7E%60%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%3B%27%3A%22%3C%3E%3F%2C.%2F"
To copy to clipboard, switch view to plain text mode 
Above 3 characters - _ and . is not encoded and its the correct thing, no problem here.




3. But temp1 shows
Qt Code:
  1. "id=~%60%21%40#%24%25%5E%26%2A%28%29_%2B-%3D%3B%27%3A%22%3C%3E%3F%2C.%2F"
To copy to clipboard, switch view to plain text mode 
Almost same as q1, but ~ and #is not encoded? Why is that



4. Value of params.query id from debugging
Qt Code:
  1. "~`%21%40#%24%25^&%2A%28%29_%2B-=%3B%27%3A"<>%3F%2C.%2F"
To copy to clipboard, switch view to plain text mode 
Many became not encoded, but not ALL. Cause as I know, without using to PercentEncoding, the @ character will not be encoded to %40





I want value of params.query id to be encoded like q1.

As you can see above, I insert q1 into params.addQuery.
But then through debugging the params.query id value and temp1 is different from q1, some characters are not encoded.

I don't use QUrl::FullyEncoded cause it does not actually encode URL reserve characters like @.Tried it
How can I fix this?