I am trying to encode POST Http queries using QUrlQuery. Reading at several places, this seems to be the solution:
QUrlQuery query;
query.addQueryItem("name","value");
QString queryString = query.query(QUrl::FullyEncoded);
but this code:
QUrlQuery query;
query.addQueryItem("calc","x+x");
qDebug() << query.query(QUrl::FullyEncoded);
Outputs:
"calc=x+x"
So the "+" did not get encoded. Why? And how do I properly encode an arbitrary String for POST parameters?
QUrlQuery is only part of QUrl.
If by encoding you mean percent encoding, then you can do it with code like this:
qDebug() << QUrl::toPercentEncoding(query.toString());