QGraphicsWebView/QWebFrame Printing issue



  • Hi

    I am trying to print a HTML page which displays in QGraphicsWebView gets print without CSS

    following is QT code:

    @
    void MainWindow::printPage(QWebFrame* wpage) {
    printer = new QPrinter(QPrinter::HighResolution);
    printer->setPaperSize(QPrinter::A4);
    printer->setFullPage(true);
    printer->setResolution(300);

    QString htmlText(wpage->toHtml());
    QPrintDialog PrintDialog(printer, this);
    if (PrintDialog.exec() == QDialog::Accepted)
    {
       QTextDocument textDocument;
       textDocument.setHtml(htmlText);
       textDocument.print(printer);
    }
    

    }
    @

    HTML page code:

    @
    <html>
    <head>
    <title>my div</title>
    [removed]
    function printDiv() {
    window.print();
    }
    [removed]
    </head>
    <body>

    <div id="printme"></div>
    <div class="container" style="border-style: dashed; border-color: #000000;">
    <div id="print" class="printable">
    <div id="example">
    <div class="modal-header">
    <a class="close" data-dismiss="modal">×</a>
    <h3>This is a Modal Heading</h3>
    </div>
    <div class="modal-body">
    <h4>Text in a modal</h4>
    <p>
    You can add some text here.
    </p>
    </div>
    <div class="modal-footer">
    <a href="#" class="btn btn-inverse btn-small" aria-hidden="true"> <i class="icon-white icon-print"></i> Print</a> 
    <button data-dismiss="modal" aria-hidden="true" class="btn btn-inverse btn-small">
    <i class="icon-white icon-remove"></i> Close
    </button>
    </div>
    </div>
    <p>
    <a data-toggle="modal" href="#example" class="btn btn-primary btn-large">Launch demo modal</a>
    </p>
    </div>
    </body>
    </html>
    @

    Please suggest me a solution as I am new to QT

    [edit: please add @ tags to make your code more readable, Eddy]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.