May 10, 2012

redlars redlars
Lab Rat
28 posts

QUrl schema

 

The following code;

  1. QUrl url2("c:\\Temp\\file.txt");
  2. cout << "url2.isValid: "     << (url2.isValid() ? "true" : "false") <<endl;
  3. cout << "url2.schema: "      << url2.scheme().toStdString() << endl;

produces this output;

  1. url2.isValid: true
  2. 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

2 replies

May 10, 2012

Andre Andre
Area 51 Engineer
6076 posts

The constructor you’re using for QUrl is broken. My docnote at the bottom of the documentation page (referenced by the link) explains this.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

May 10, 2012

redlars redlars
Lab Rat
28 posts

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

 
  ‹‹ Organizing the code      Qt Quick programs for Desktop? ››

You must log in to post a reply. Not a member yet? Register here!