문제

QUrl url("bword://blood transfusion");
QString res = url.toString();

Why I got the string "bword:" instead of "bword://blood transfusion"?

How can I get the string "bword://blood transfusion" form the QUrl?

도움이 되었습니까?

해결책

URL syntax can be quite complex, see this Wikipedia article. The problem is that your URL does not contain authority field, it only has scheme field "bword" and path "//blood transfusion". And according to the RFC3986 - Uniform Resource Identifier (URI): Generic Syntax:

When authority is not present, the path cannot begin with two slash characters ("//").

So your URL is not valid (although isValid() returns true). Change your code to:

QUrl url("bword:/blood transfusion");
QString res = url.toString();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top