From 4d691cfc8ad2ddcdb72209cc19752ed5c8bbb577 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Thu, 9 Nov 2023 11:20:42 +0100 Subject: [PATCH] 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.5 Change-Id: I8bd93d11aefee0344725ac51c2490d029657f483 Reviewed-by: Laszlo Agocs (cherry picked from commit 2ac50bb0f539b1ee62503ff136063c693d4662e9) Reviewed-by: Qt Cherry-pick Bot --- src/printsupport/kernel/qplatformprintdevice.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp index 0ea0242edd4..a2ee51f8872 100644 --- a/src/printsupport/kernel/qplatformprintdevice.cpp +++ b/src/printsupport/kernel/qplatformprintdevice.cpp @@ -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);