tags:

views:

12

answers:

1

I have a QUrl and I need to extract the path+file+params. Basically everything but the hostname - what would be requested via HTTP.

I looked through the Qt 4.6 docs but I couldn't find anything that looked like it would do this.

What method(s) would I call?

+1  A: 

You can clear the scheme with setScheme. After that the url will be relative so it shouldn't return the hostname anymore when converting it to a string.

QUrl someUrl("http://stackoverflow.com/foo/bar?spam=eggs");
someUrl.setScheme("");
someUrl.toString();

Or, you can give the toString() method some extra parameters:

QUrl someUrl("http://stackoverflow.com/foo/bar?spam=eggs");
someUrl.toString(QUrl::RemoveScheme);
WoLpH
Thanks. That'll work just great. One more question - when I call toString, does it return a URL-encoded string?
George Edison
For an urlencoded `toString` you can use `toEncoded`.Docs: http://doc.trolltech.com/4.6/qurl.html#toEncoded
WoLpH