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

QPrinter::pageRect changed after QPrintDialog is shown

XMLWordPrintable

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

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

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

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

              Created:
              Updated:

                There are no open Gerrit changes