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

QPrinter::pageRect changed after QPrintDialog is shown

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 4.8.3
    • GUI: Printing
    • None
    • Windows 7, Mac OS
    • macOS, Windows

    Description

      QPrinter::pageRect() returns different value before QPrinterDialog is shown to what it is after the printing. Setting the paper size before this makes no difference.

      The issue can be reproduced with the textedit demo by adding the following debug prints and paper size setting to TextEdit::filePrint() method

          QPrinter printer(QPrinter::HighResolution);
          printer.setPaperSize(QPrinter::A4);
          qDebug() << printer.pageRect(QPrinter::Millimeter);
          QPrintDialog *dlg = new QPrintDialog(&printer, this);
          if (textEdit->textCursor().hasSelection())
              dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
          dlg->setWindowTitle(tr("Print Document"));
          if (dlg->exec() == QDialog::Accepted) {
              textEdit->print(&printer);
          }
          delete dlg;
          qDebug() << printer.pageRect(QPrinter::Millimeter);
      

      Attachments

        Issue Links

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

          Activity

            People

              Unassigned Unassigned
              qtcomsupport Qt Support
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes