From 4fcbbc99fd88ad0df25c6bd56ccb61ee51ada630 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 20 Mar 2020 10:19:31 +0200 Subject: [PATCH] Make sure that printer page layout switched to millimeters before getting margins. --- src/app/valentina/mainwindowsnogui.cpp | 4 +++- src/libs/vlayout/vposter.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index b26cd28cc..74c946e94 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -973,7 +973,9 @@ void MainWindowsNoGUI::PrintPages(QPrinter *printer) qreal x,y; 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)); y = qFloor(ToPixel(printerMargins.top(),Unit::Mm)); } diff --git a/src/libs/vlayout/vposter.cpp b/src/libs/vlayout/vposter.cpp index b278c564e..6f3bda890 100644 --- a/src/libs/vlayout/vposter.cpp +++ b/src/libs/vlayout/vposter.cpp @@ -431,7 +431,9 @@ QRect VPoster::PageRect() const 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); const QRect pageRectFP(0, 0, qFloor(ToPixel(newRect.width())), qFloor(ToPixel(newRect.height()))); return pageRectFP;