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

qt_convertMargins rounding points to 0 decimal places causes problem for printers



    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.5
    • Fix Version/s: None
    • Component/s: GUI: Printing
    • Labels:
    • Environment:
      openSUSE Tumbleweed 20210726
      KDE Plasma 5.22.3
      KDE Frameworks 5.84.0
      Qt 5.15.5
    • Platform/s:


      On this line of code (https://github.com/qt/qtbase/blob/9db7cc79a26ced4997277b5c206ca15949133240/src/gui/painting/qpagelayout.cpp#L102), the qt_convertMargins() function in Qt will round the point to 0 decimal places when the toUnits parameter is set to "QPageLayout::Point".

      This creates problem when the printer ppd file provides a non-int margin. For example, my EPSON ET-2760 printer has a margin of 8.40 points for both A4 and US Letter page sizes. When the default margin size has decimals, the valid check here(https://code.woboq.org/qt5/qtbase/src/printsupport/kernel/qplatformprintdevice.cpp.html#_ZNK20QPlatformPrintDevice17isValidPageLayoutERK11QPageLayouti) will return false when the layout unit is set to millimeters, because 8.40 pts will be converted to 2.96 mm, which is further rounded to 8 pt. Eventually, this will cause all page size settings (such as US Letter) to be incorrectly set to A4 (default).


      Note that this won't happen when the layout unit is in, because 8.40 pts == 0.116 in, which is rounded to 0.12 in in the QPageSetup dialog, and 0.12 in will be rounded to 9 pts.


      My question is, what is the reason of rounding 0 decimal places in qt_convertMargins() when toUnits is pts? If not, Qt should fix it by using 2 or more decimal places.


      Ideally, Qt whould also check the return value of setPageSize() (https://github.com/qt/qtbase/blob/9db7cc79a26ced4997277b5c206ca15949133240/src/printsupport/dialogs/qpagesetupdialog_unix.cpp#L531). This bug will expose much earlier if qpagesetupdialog checks the return value of setPageSize().


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



            johnlayt John Layt
            xzhao Xu Zhao
            0 Vote for this issue
            1 Start watching this issue



                Gerrit Reviews

                There are no open Gerrit changes