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

QPrinter::paperSize() returns incorrect paper size on QPageSetupDialog

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.3.0 Beta1
    • 4.7.3
    • GUI: Printing
    • None
    • Windows 7

      Launch the QPageSetupDialog and request the paper size selected by user:

      QPageSetupDialog myPageSetupDialog(myQPrinter, this);
      if (myPageSetupDialog.exec() == QDialog::Accepted) {
      QPrinter::PaperSize size = myQPrinter->paperSize();

      QPrinter::paperSize() returns the paper size based on the lookup table in %QTDIR%\src\gui\painting\qprintengine_win.cpp, which rather than mapping some unusual paper sizes to QPrinter::Custom, actually maps them to other paper sizes (function mapDevmodePaperSize(int s) on qprintengine_win.cpp).

      This works ok if the original paper size either maps identically or doesn't appear in the table. But if the user selects a paper size that is non-identically mapped, QPrinter::paperSize() returns incorrect paper size. E.g. if 'A4 Extra' selected on QPageSetupDialog --> QPrinter::paperSize() returns 'A4'.

      These alternative sizes get returned also if you request the actual dimensions as it maps to the QPrinter::PaperSize alternative before looking up the dimensions.

      Note: if QPrintPreviewWidget is used with same QPrinter instance, it returns the paper size correctly (from the DEVMODE structure held inside the QPrinter code hierarchy).

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

            johnlayt John Layt
            qtcomsupport Qt Support
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes