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

QPrinter::setPaperSize( const QSizeF&, Unit) causes invalid paper size on Mac

    XMLWordPrintable

Details

    • macOS
    • 5f35882f91ff5634b1694d1f6d62c057d278b1a6

    Description

      Whenever you use the QPrinter::setPaperSize overload that accepts a QSizeF& and QPrinter::Unit on the Mac, it corrupts the paper size structure internally, causing printouts to render in completely the wrong location. If you specify the exact same paper size using the overload that accepts a QPrinter::PaperSize, it works fine.

      main.cpp
      #include <QtCore>
      #include <QtGui>
      int main(int argc, char **argv) {
        QApplication app(argc, argv);
        QPrinter printer(QPrinter::HighResolution);
        printer.setPaperSize(QSizeF(8.5, 11.0), QPrinter::Inch);
        // printer.setPaperSize(QPrinter::Letter);  // <- this will work fine.
        QPrintDialog dialog(&printer);
        if (dialog.exec() == QDialog::Accepted) {
          QPainter painter(&printer);
          painter.drawEllipse(0, 0, 100, 100);
        }
      }
      

      The expected output would have a circle in the top-left corner. The actual output puts in near the bottom-left, but not entirely in the corner. It thinks that point (0,0) is somewhere near the bottom of the page.

      Attachments

        For Gerrit Dashboard: QTBUG-18723
        # Subject Branch Project Status CR V

        Activity

          People

            andysh Andy Shaw
            dmateer Dave Mateer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes