QPrinter: allow any margins when setting a fullpage QPageLayout

By default, QPrinter::setPageLayout correctly rejects a layout that
specifies margins outside the printable area. However, when the layout
specifies fullpage mode, that check should be skipped, since then one
should be allowed to target the unprintable area, by definition.

Fixes: QTBUG-118580
Pick-to: 6.6 6.5
Change-Id: I8bd93d11aefee0344725ac51c2490d029657f483
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Eirik Aavitsland 2023-11-09 11:20:42 +01:00
parent 52eae99b51
commit 2ac50bb0f5

View File

@ -75,6 +75,10 @@ bool QPlatformPrintDevice::isValidPageLayout(const QPageLayout &layout, int reso
if (!supportedPageSize(layout.pageSize()).isValid())
return false;
// In fullpage mode, margins outside the printable area are valid
if (layout.mode() == QPageLayout::FullPageMode)
return true;
// Check the margins are valid
QMarginsF pointMargins = layout.margins(QPageLayout::Point);
QMarginsF printMargins = printableMargins(layout.pageSize(), layout.orientation(), resolution);