title: How to get the source QString instance from a QUrl instance which is invalid?
body: <p>I have constructed a <strong>QUrl</strong> instance like below.</p>
  
  <p><a href="https://i.stack.imgur.com/WwPCq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WwPCq.png" alt="enter image description here"></a></p>
  
  <p>Here is a output from <strong>PyQt4</strong>, actually i use <strong>Qt5</strong>, but it isn't installed on this machine, so it's just a sample code to demonstrate my problem.</p>
  
  <p>In <strong>Qt5</strong>, i want to get the <strong>source</strong> string "test.pro://account=" from the <strong>QUrl</strong> instance, how can i achieve it?</p>
  
  <p>What i have done?</p>
  
  <p>The <strong>QUrl</strong> class have a private class which is named <strong>QUrlPrivate</strong> which contains a struct named <strong>Error</strong>. The <strong>Error</strong> structure contains <strong>QString</strong> source which is actually what i want. But i don't know how to access it usinig public API from <strong>QUrl</strong>.</p>
  
  <p>Thanks for helping.</p>
  
  <p>In addtion:</p>
  
  <p>I use <strong>PyQt5</strong> on <strong>Mac Os</strong>.</p>
  
  <p>I want to handle <a href="https://stackoverflow.com/questions/6561661/url-scheme-qt-and-mac">Url Scheme</a>.</p>
  
  <p>In fact, in this case, <strong>PyQt5</strong> is equal to <strong>Qt5</strong>. You can test using <strong>Qt5</strong>.</p>
  
  <p><strong>Qt</strong> has source code below, which means it will convert <strong>NSString</strong> to <strong>QString</strong> and convert <strong>QString</strong> to <strong>QUrl</strong> and construct a <strong>QFileOpenEvent</strong> using this <strong>QUrl</strong> instance and send <strong>QApplication</strong> instance the <strong>QFileOpenEvent</strong> instance.</p>
  
  <pre><code>- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
  {
      [event paramDescriptorForKeyword:keyDirectObject] ;
  
      NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
  
      QWindowSystemInterface::handleFileOpenEvent(QUrl(QCFString::toQString(urlString)));
  }
  </code></pre>
  
  <p>In my <strong>PyQt5</strong> app, i have reimplemented <strong>event</strong> method of <strong>QApplication</strong> instance.</p>
  
  <pre><code>def event(self, e):
      if e.type() == QEvent.FileOpen:
          print e.url().toString()
  </code></pre>
  
  <p>But i can't get source string "test.pro://account=" from <strong>QUrl</strong>.</p>
  
  <p>This is all the context. </p>
  
  <p>In fact, where i want to do my work is in <strong>event</strong> handler, so i want to get the source string from <strong>QUrl</strong> instance.</p>