This turned out to be a tricky problem. Here is the solution I came up with:
Code
QByteArray rawQuery("t=somekeyword&p=%01");
QUrl command("http://192.168.11.11/subdomain/letters");
command.setEncodedQuery(rawQuery);
std::cout << command.toEncoded().data();
Result
http://192.168.11.11/subdomain/letters?t=somekeyword&p=%01
Notes
The solution relies on some behavior described in setEncodedQuery, which states
Sets the query string of the URL to query. The string is inserted as-is, and no further encoding is performed when calling toEncoded().
This function is useful if you need to pass a query string that does not fit into the key-value pattern, or that uses a different scheme for encoding special characters than what is suggested by QUrl.
Passing a value of QByteArray() to query (a null QByteArray) unsets the query completely. However, passing a value of QByteArray("") will set the query to an empty value, as if the original URL had a lone "?".
References