QUrl and special characters(#)
-
My Qt-based client is sending a HTTP request to a server with Qurl, for example
@
netManager = new QNetworkAccessManager(this);
netManager->get(QNetworkRequest(QUrl("http://www.somesite.com/query.php?file=filename")));
@The problem is the filename I passed as a PHP parameter can contain some special characters like "#".
"/path/to/some#file" is a valid file path, but if I pass this string in QUrl, the #file will get truncated because
"#" is recognized as fragment indicator(or "named anchor"), so the server side PHP program will receive a query
with file name set to "/path/to/some", that's not my intention.Do I have to work around this problem by myself? or is there any existing solution with QUrl?
-
OK, I figured out that I should not use QUrl::QUrl ( const QString & url ).
QUrl's member functions setScheme() setAuthority() setPath() setQueryItems() solved my problem. -
as a side not, AFAIK this will be fixed in Qt5.