Important: Please read the Qt Code of Conduct -

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);

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


    HTML page code:

    <title>my div</title>
    function printDiv() {

    <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 class="modal-body">
    <h4>Text in a modal</h4>
    You can add some text here.
    <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
    <a data-toggle="modal" href="#example" class="btn btn-primary btn-large">Launch demo modal</a>

    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