Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-30937

Alignment issue while printing from QWebView to the printer.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3: Somewhat important
    • None
    • 5.0.1, 5.1.0 RC1
    • WebKit
    • None
    • Windows 7/32bit, Qt 5.0.1

    Description

      I tried displaying the simple HTML file in the qwebview, and sending the same to the printer. But Unfortunatly the output is not aligned properly.

      Here is the Code:

      myView.h:
      ---------

      class myView : public QWebView

      { Q_OBJECT public: explicit myView(QWidget * parent = 0); private slots: void onLoadFinished(bool b); }

      ;

      MyView.cpp:
      -----------

      myView::myView(QWidget *parent):QWebView(parent)
      {
      QObject::connect(page()->mainFrame(), SIGNAL(loadFinished(bool)), SLOT(onLoadFinished(bool)));
      setHtml("<html><body>Welcome <br> <table border=1> <tr><td> row1,col1 </td></tr><tr><td>row2, Col1</td></tr></table> </body></html>");
      }

      void myView::onLoadFinished(bool b)
      {
      settings()->setAttribute(QWebSettings::PrintElementBackgrounds, true);
      QPrinter printer;
      printer.setPageSize(QPrinter::A4);
      printer.setOrientation(QPrinter::Portrait);
      QPrintDialog *dlog = new QPrintDialog (&printer, this);

      if ( dlog->exec () == QDialog::Accepted)

      { print(&printer); }

      }

      Main.cpp:
      ---------
      int main(int argc, char *argv[])
      {
      QApplication a(argc, argv);
      myView *mv = new myView();
      mv->show();
      return a.exec();
      }

      Have tried setting several options to the QPrinter, but the result is the same.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mibrunin Michael Bruning
            jelari Ramprakash Jelari
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes