Honor QPrinter::setFullPage(true) on Windows too (no margins)
fullPage means the print engine shouldn't add any margins, the application will take care of that. That's already what happens on Linux and Mac, but the Windows print engine was offset-ting everything to the bottom right by the value of the margins, erroneously. As noted in QTBUG-95927, the workaround for this bug was to call printer.setPageMargins(QMargins(0,0,0,0)); when using printer.setFullPage(true), and this fix is compatible with that workaround, existing apps won't be broken. [ChangeLog][QtPrintSupport][Windows] setFullPage(true) now behaves as expected, i.e. the QPrinter margins are ignored and the drawing's (0, 0) is the topleft corner of the page. This is what setFullPage(true) is documented to do, and how it was already working on other operating systems. If this causes regressions in your application, consider removing the call to setFullPage(true) so that the painting honors the margins again. Fixes: QTBUG-119003 Fixes: QTBUG-95927 Change-Id: Ia3d621302bf752833002614303dd64128027163a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
6901ad665d
commit
652065b06b
@ -1707,7 +1707,8 @@ void QWin32PrintEnginePrivate::updateMetrics()
|
||||
m_paintSizeMM = QSize(qRound(sizeMM.width()), qRound(sizeMM.height()));
|
||||
// Calculate the origin using the physical device pixels, not our paint pixels
|
||||
// Origin is defined as User Margins - Device Margins
|
||||
QMarginsF margins = m_pageLayout.margins(QPageLayout::Millimeter) / 25.4;
|
||||
const bool isFullPage = (m_pageLayout.mode() == QPageLayout::FullPageMode);
|
||||
const QMarginsF margins = isFullPage ? QMarginsF() : (m_pageLayout.margins(QPageLayout::Millimeter) / 25.4);
|
||||
origin_x = qRound(pageScaleX * margins.left() * dpi_x) - GetDeviceCaps(hdc, PHYSICALOFFSETX);
|
||||
origin_y = qRound(pageScaleY * margins.top() * dpi_y) - GetDeviceCaps(hdc, PHYSICALOFFSETY);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user