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

QPrinter::setFullPage does not set margins to zero

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.0
    • Fix Version/s: None
    • Component/s: GUI: Printing
    • Labels:
      None
    • Environment:
      Tested on Windows

      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

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

          Activity

            People

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

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes