I have a QWebView and am trying to determine the mime type of a clicked link, so I can hand-off the loading of a PDF, for example.

So, in my browser subclass, I handle a link click:

Qt Code:
  1. connect(this, &QWebView::linkClicked, this, &BrowserView::onLinkClicked);
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. void BrowserView::onLinkClicked(const QUrl & url)
  2. {
  3. QMimeDatabase mime;
  4. qDebug() << "mime type" << mime.mimeTypeForUrl(url).name();
  5. ...
  6. }
To copy to clipboard, switch view to plain text mode 

The problem is, the mime type always comes back as "application/octet-stream", which is the default if Qt can't parse the mime-type.

However, I'm clicking on links which are known PDF files. For example, any of the links here: https://www.google.com/?gws_rd=ssl#q=example+pdf

Isn't there a way to get the mime type from a URL for a known type, like a PDF?