Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. QGraphicsWebView/QWebFrame Printing issue
Forum Updated to NodeBB v4.3 + New Features

QGraphicsWebView/QWebFrame Printing issue

Scheduled Pinned Locked Moved Qt WebKit
1 Posts 1 Posters 776 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sushant_mokal
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved