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

QPrinter pageLayout().paintRect not working correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7.2
    • GUI: Printing
    • None
    • Windows

    Description

      1) Start in portrait mode and set page margins:

      qDebug() << printer.pageLayout().pageSize().rect(QPageSize::Millimeter);

      OUTPUT: QRectF(0,0 210x297)

      bool b=printer.setPageMargins(QMarginsF(20,30,40,50), QPageLayout::Millimeter);
      Q_ASSERT(b);
      QRectF r_portrait=printer.pageLayout().paintRect(QPageLayout::Millimeter);
      qDebug() << printer.pageLayout().paintRect(QPageLayout::Millimeter) << printer.pageLayout().margins(QPageLayout::Millimeter);

      OUTPUT: QRectF(20,30 150x217) QMarginsF(20, 30, 40, 50)

      2) Set orientation to landscape mode:

      auto pageLayout=printer.pageLayout();
      pageLayout.setOrientation(QPageLayout::Landscape);
      b=printer.setPageLayout(pageLayout);
      Q_ASSERT(b);
      qDebug() << printer.pageLayout().paintRect(QPageLayout::Millimeter) << printer.pageLayout().margins(QPageLayout::Millimeter);

      OUTPUT: QRectF(20,30 237x130) QMarginsF(20, 30, 40, 50)

      I would assume:

      QRectF(30,20, 217x150)

       

      One practical example: I used the "Canon E410 series" dot-printer as test printer. The physical margins are: (3.39, 2.96, 3.39, 16.72).

      I want to stretch a picture on the whole paint area in landscape mode, but with the default margins the right side is cut off and the bottom margin is too long.

      I tried to set the margins manually, but because they refer to portrait mode, new values where not accepted (physical limitation of the printer).

      There was no other way than to calculate the rotated rect alone and to use QPrinter.setFullPage(true).

       

       

       

       

       

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            the_robz Robert Mundt
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes