title: How to make QWebView conserve return values from modal windows?
body: <p>What makes this small browser app fail to return the window.returnValue given in the modal window? The <a href="http://qt.gitorious.org/qt/qt/trees/4.8/demos/browser" rel="nofollow">Qt Browser demo</a> does make it work, but I can't figure why it does and this mini browser app doesn't.</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QWebView&gt;
  #include &lt;QWebPage&gt;
  #include &lt;QUrl&gt;
  
  class WebPage : public QWebPage
  {
  public:
      QWebPage *createWindow(QWebPage::WebWindowType type)
      {
          QWebView *wv = new QWebView;
          if (type == QWebPage::WebModalDialog)
              wv-&gt;setWindowModality(Qt::ApplicationModal);
          return wv-&gt;page();
      }
  };
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      QWebView view;
  
      QWebSettings::globalSettings()-&gt;setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
  
      view.setPage(new WebPage);
      view.load(QUrl("http://help.dottoro.com/external/examples/ljdlgxbu/showModalDialog_1.htm"));
      view.show();
  
      return a.exec();
  }
  </code></pre>
  
  <p><a href="https://developer.mozilla.org/en-US/docs/DOM/window.showModalDialog" rel="nofollow">showModalDialog()</a> is synchronous and should return the value set as window.returnValue in the modal dialog created by the call. The small browser app opens the dialog window successfully, but the (modal)window.returnValue is not set as return value for showModalDialog().</p>