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

QPrinter::setFullPage does not set margins to zero

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.8.0 FF
    • 5.15.0
    • GUI: Printing
    • None
    • Tested on Windows
    • 652065b06 (dev)

    Description

      According to the docs, calling QPrinter::setFullPage(true), should result in the origin of the QPrinter's coordinate system coincides with the top-left corner of the paper itself. This doesn't seem to be true.

      Example

      QPrinter printer;
      QPrintDialog dlg (&printer);
      if (dlg.exec() == QtDialog::Accepted)
      {
        printer.setFullPage(true);
      //  printer.setPageMargins(QMargins(0,0,0,0)); // explicitly setting the margins to zero, fixes the bug.
      
        qDebug () << printer.margins().left << printer.margins().top << printer.margins().right << printer.margins().bottom; // Does not return zero (actual values depend on the default printer)
      
        QPainter p(&printer);
        p.drawRect(0,0,100, 100); // Rectangle will not coincide with the top left of the page.
      }
      

      **Note that the problem only occurs if the default printer has a default margin not equal to zero.

      Possible solution

      Explicitly call setPageMargins(QMargins(0,0,0,0)); when setFullPage(true); is called.

      Attachments

        Issue Links

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

          Activity

            People

              johnlayt John Layt
              skmyro Geert Mys
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes