title: How to save dynamically generated web page in QWebEngineView?
body: <p>I am loading a web page onto <code>QWebEngineView</code>. A user creates a different kind of tables (reports) and then needs to save those tables to local computer as a web page. Here is what I have tried:</p>
  
  <ol>
  <li><p>Here I use a <code>QWebEnginePage::save()</code> method, but nothing happens:</p>
  
  <pre><code>connect(saveButton, &amp;QPushButton::clicked, this, [this]()
  {
     engineWebView-&gt;page()-&gt;save("save.html");
  });
  </code></pre></li>
  <li><p>Then I tried a QWebEngineProfile::download() method:</p></li>
  </ol>
  
  <pre class="lang-cpp prettyprint-override"><code>    connect(saveButton, &amp;QPushButton::clicked, this, [this]()
      {
          engineWebView-&gt;page()-&gt;download(engineWebView-&gt;page()-&gt;url(), "save");
      });
      connect(engineWebView-&gt;page()-&gt;profile(), &amp;QWebEngineProfile::downloadRequested, this, [this](QWebEngineDownloadItem *download) 
      {
          download-&gt;setPath("save.html");
          download-&gt;accept();
      });
  </code></pre>
  
  <p>In the second solution, I can save only the first loaded webpage. No dynamically created content.</p>
  
  <p>How do I save a dynamically created data?</p>
  
  <p><hr/>
  <strong>Edit</strong>: minimal reproducible code:</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QDebug&gt;
  #include &lt;QFile&gt;
  #include &lt;QHBoxLayout&gt;
  #include &lt;QPushButton&gt;
  #include &lt;QWebEngineProfile&gt;
  #include &lt;QWebEngineView&gt;
  
  int main(int argc, char *argv[])
  {
      QApplication app(argc, argv);
  
      QWebEngineView *engine = new QWebEngineView;
      QObject::connect(engine-&gt;page()-&gt;profile(), &amp;QWebEngineProfile::downloadRequested, [](QWebEngineDownloadItem *download) {
          download-&gt;setPath("download.html");
          download-&gt;accept();
      });
  
      QPushButton *saveButton = new QPushButton("Save");
      QObject::connect(saveButton, &amp;QPushButton::clicked, [engine]()
      {
          engine-&gt;page()-&gt;save("save.html");
      });
  
      QPushButton *toHtmlButton = new QPushButton("ToHtml");
      QObject::connect(toHtmlButton, &amp;QPushButton::clicked, [engine]()
      {
          engine-&gt;page()-&gt;toHtml([](QString html){
          QFile file("toHtml.html");
          if (file.open(QFile::WriteOnly | QFile::Text))
          {
              QTextStream stream(&amp;file);
              stream &lt;&lt; html;
              file.waitForBytesWritten(-1);
              file.close();
          }
          else
              qDebug() &lt;&lt; "Cannot create a file";
          });
      });
  
      QPushButton *downloadButton = new QPushButton("Download");
      QObject::connect(downloadButton, &amp;QPushButton::clicked, [engine]()
      {
          engine-&gt;page()-&gt;download(engine-&gt;page()-&gt;url());
      });
  
      QHBoxLayout *hLyt = new QHBoxLayout;
      hLyt-&gt;addWidget(saveButton);
      hLyt-&gt;addWidget(toHtmlButton);
      hLyt-&gt;addWidget(downloadButton);
  
      QVBoxLayout *vLyt = new QVBoxLayout;
      vLyt-&gt;addLayout(hLyt);
      vLyt-&gt;addWidget(engine);
  
      QWidget *mainWin = new QWidget;
      mainWin-&gt;setLayout(vLyt);
      mainWin-&gt;show();
  
      // The url is an example for react usage. I am generating data using ReactJS that's why I use this example. What I need is to store the exact view of the dynamically generated calculator        
      engine-&gt;load(QUrl("https://ahfarmer.github.io/calculator/"));
  
      return app.exec();
  }
  </code></pre>