Pergunta

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?

Foi útil?

Solução

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();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top