Important: Please read the Qt Code of Conduct -

QUrl schema

  • The following code;
    @QUrl url2("c:\Temp\file.txt");
    cout << "url2.isValid: " << (url2.isValid() ? "true" : "false") <<endl;
    cout << "url2.schema: " << url2.scheme().toStdString() << endl;

    produces this output;
    url2.isValid: true
    url2.schema: c

    Why is the schema equal to "c"? Is this correct behaviour ?

    By changing the QUrl constructor parameter to "file://c:/Temp/file.txt" then schema is "file" which is as expected.

    Using Qt 4.7.1

  • The constructor you're using for [[doc:QUrl]] is broken. My docnote at the bottom of the documentation page (referenced by the link) explains this.

  • Thanks for quick and good response. Sorry missed your comment.

Log in to reply