title: Handling Downloads in QtWebEngine
body: <p>We are currently migrating a project from the <code>QtWebkit</code> to the <code>QWebEngine</code>. However, handling downloads is causing a bit of a headache. Previously we handled this using the <code>QWebPage::unsupportedContent</code> signal, like so:</p>
  
  <pre><code>QWebPage* webPage = new QWebPage(this);
  
  QObject::connect(webPage, &amp;QWebPage::unsupportedContent, [] (QNetworkReply* reply) {
      // do stuff with the reply
      reply-&gt;readAll();
  });
  </code></pre>
  
  <p>When using <code>QtWebEngine</code>, the only thing I can think of is to use the <code>QWebEngineView::urlChanged</code> signal to make a request to the server and i'm not even sure if that will work.</p>
  
  <pre><code>QNetworkAccessManager* accessManager = new QNetworkAccessManager(this);
  QWebEngineView* webView = new QWebEngineView(this);
  
  QObject::connect(webView, &amp;QWebEngineView::urlChanged, [=] (const QUrl&amp; url) {
      if (url.path().endsWith("some_endpoint_which_results_in_a_download") {
          QNetworkReply* reply = accessManager-&gt;get(url);
          // do the same stuff to the reply
          reply-&gt;readAll();
      }
  })
  </code></pre>
  
  <p>Obviously this approach is very limiting in that the endpoints which result in a download must be hard-coded into the application. However, I cant see a better solution. Has anyone come up with anything better?</p>
  
  <p>-- Update --</p>
  
  <p>The Docs from Qt's <a href="http://wiki.qt.io/New-Features-in-Qt-5.5" rel="noreferrer">5.5 Release plan</a> outlines, among other improvements to the developer's control over the web cache and cookies, the following feature.</p>
  
  <blockquote>
    <p>Added API for managing downloading of files</p>
  </blockquote>
  
  <p>5.5 beta is intended for release on 09/04/2015 and the final for release on 26/05/2015.</p>
  
  <p>To prevent any further head trauma, it may be worth just waiting for these improvements.</p>
  
  <p>Having said that, I'd still be interested in a cleaner solution than mine if anyone has one.</p>