문제

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?

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top