Make sure that printer page layout switched to millimeters before getting margins.

This commit is contained in:
Roman Telezhynskyi 2020-03-20 10:19:31 +02:00
parent 5e587591f0
commit 4fcbbc99fd
2 changed files with 6 additions and 2 deletions

View File

@ -973,7 +973,9 @@ void MainWindowsNoGUI::PrintPages(QPrinter *printer)
qreal x,y; qreal x,y;
if(printer->fullPage()) if(printer->fullPage())
{ {
QMarginsF printerMargins = printer->pageLayout().margins(); QPageLayout layout = printer->pageLayout();
layout.setUnits(QPageLayout::Millimeter);
QMarginsF printerMargins = layout.margins();
x = qFloor(ToPixel(printerMargins.left(),Unit::Mm)); x = qFloor(ToPixel(printerMargins.left(),Unit::Mm));
y = qFloor(ToPixel(printerMargins.top(),Unit::Mm)); y = qFloor(ToPixel(printerMargins.top(),Unit::Mm));
} }

View File

@ -431,7 +431,9 @@ QRect VPoster::PageRect() const
if(printer->fullPage()) if(printer->fullPage())
{ {
QMarginsF pMargins = printer->pageLayout().margins(); QPageLayout layout = printer->pageLayout();
layout.setUnits(QPageLayout::Millimeter);
QMarginsF pMargins = layout.margins();
QRectF newRect = rect.marginsRemoved(pMargins); QRectF newRect = rect.marginsRemoved(pMargins);
const QRect pageRectFP(0, 0, qFloor(ToPixel(newRect.width())), qFloor(ToPixel(newRect.height()))); const QRect pageRectFP(0, 0, qFloor(ToPixel(newRect.width())), qFloor(ToPixel(newRect.height())));
return pageRectFP; return pageRectFP;