title: Cannot move to next page to print HTML content with QPrinter
body: <p>In my small application, I want to preview some HTML content in each page so I used the following code</p>
  
  <pre><code>/*
  * Handle events when clicking button to preview content
  */
  void MainWindow::on_pushButton_clicked()
  {
      QPrinter printer;
      printer.setPaperSize(QPrinter::A4);
      printer.setOrientation(QPrinter::Portrait);
      printer.setFullPage(true);
  
      QPrintPreviewDialog *printPreview = new QPrintPreviewDialog(&amp;printer);
      connect(printPreview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printAllTitle(QPrinter*)));
  
      printPreview-&gt;setWindowTitle("Demo");
      Qt::WindowFlags flags(Qt::WindowTitleHint);
      printPreview-&gt;setWindowFlags(flags);
      printPreview-&gt;showMaximized();
      printPreview-&gt;exec();
  }
  
  /*
  * Show preview content
  */
  void MainWindow::printAllTitle(QPrinter *printer)
  {
      QVector&lt;QString&gt; titles;
      titles.push_back("Title 1");
      titles.push_back("Title 2");
  
      QString strStream;
      QTextStream out(&amp;strStream);
  
      for (int i = 0; i &lt; titles.size(); i++) {
          out &lt;&lt; "&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;";
          out &lt;&lt; "&lt;p style=\"font-size:20pt\"&gt;" + titles.at(i) + "&lt;/p&gt;";
          out &lt;&lt; "&lt;/body&gt;&lt;/html&gt;";
  
          printer-&gt;newPage();   // Don't move the next page !!!
      }
  
      QTextDocument *document = new QTextDocument();
      document-&gt;setHtml(strStream);
      document-&gt;print(printer);
      delete document;
  } 
  </code></pre>
  
  <p>And the result page I got</p>
  
  <p><img src="https://i.stack.imgur.com/5qATo.png" alt="Cannot move the next page"></p>
  
  <p>After testing the result page many times, I realized that the Printer didn't move the next page to print HTML content.</p>
  
  <p>How can I solve this issue?</p>
  
  <p>Thanks!</p>