c++ - QWebView not printing multiple pages on real printer? -


well i'm trying print qwebview multiple pages, using css page-break attribute, works fine webkit. i'm using qt 5.1.1.

my main problem fine when i'm printing pdf using qt, when i'm trying print real printer, pages first 1 blank! here (stripped) test's code :

test.h :

class mainwindow : public qmainwindow, private ui::mainwindow {   q_object  public:     explicit mainwindow(qwidget *parent = 0);  public slots:     void printhtml();     void printpreview(qprinter *printer); private:     qwebview webview; }; 

test.cpp :

#include "test.h"  mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent) {     qstring html;     html= "<!doctype html><html>  <head>    <meta http-equiv='content-type' content='text/html;charset=utf-8' />    <title>paginated html</title>    <style type='text/css' media='print'>      div.page      {        page-break-after: always;        page-break-inside: avoid;      }    </style>  </head>  <body>    <div class='page'>      <h1>this page 1</h1>    </div>    <div class='page'>      <h1>this page 2</h1>    </div>    <div class='page'>      <h1>this page 3</h1>    </div>  </body></html>";      webview.sethtml(html);     printhtml(); }  void mainwindow::printpreview(qprinter *printer)  {    webview.print(printer); }  void mainwindow::printhtml()  {     qprinter printer;     qprintpreviewdialog preview(&printer);     preview.setwindowtitle("test imp");      connect(&preview, signal(paintrequested(qprinter*)), this, slot(printpreview(qprinter*)));      preview.exec();      this->close(); } 

i've embed html example string, example works fine other webkit engine , prints well.

the preview display should print, , when print using print button of preview, print first page without problem remaining pages totally empty, blank.

i wasn't able find workaround, using qpainter render out of question, since need have multiple pages , qpainter isn't way manage multiple pages (at least don't know how if it's able : never saw qpainter manage multiple pages after rendering.)

ps : try yourself, adding

    printer.setoutputformat(qprinter::pdfformat); 

just after qprinter declaration works fine, it's saving pdf , displayed every pages printed out nicely. problem, since need print normal printer , avoid saving pdf , printing pdf.

this has never been corrected in qt, qwebview have been replaced qwebengine , not suffer these problems when printing pages.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -