Remove deprecated QPrinter methods.
This commit is contained in:
parent
e70e998dc5
commit
c3142b8b07
|
@ -1308,7 +1308,7 @@ void MainWindowsNoGUI::PdfFile(const QString &name, QGraphicsRectItem *paper, QG
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
if (painter.begin( &printer ) == false)
|
if (not painter.begin( &printer ))
|
||||||
{ // failed to open file
|
{ // failed to open file
|
||||||
qCritical("%s", qUtf8Printable(tr("Can't open printer %1").arg(name)));
|
qCritical("%s", qUtf8Printable(tr("Can't open printer %1").arg(name)));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -315,24 +315,21 @@ QMarginsF GetMinPrinterFields(const QSharedPointer<QPrinter> &printer)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QMarginsF GetPrinterFields(const QSharedPointer<QPrinter> &printer)
|
auto GetPrinterFields(const QSharedPointer<QPrinter> &printer) -> QMarginsF
|
||||||
{
|
{
|
||||||
if (printer.isNull())
|
if (printer.isNull())
|
||||||
{
|
{
|
||||||
return QMarginsF();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal left = 0;
|
|
||||||
qreal top = 0;
|
|
||||||
qreal right = 0;
|
|
||||||
qreal bottom = 0;
|
|
||||||
printer->getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter);
|
|
||||||
// We can't use Unit::Px because our dpi in most cases is different
|
// We can't use Unit::Px because our dpi in most cases is different
|
||||||
|
const QMarginsF m = printer->pageLayout().margins(QPageLayout::Millimeter);
|
||||||
|
|
||||||
QMarginsF def;
|
QMarginsF def;
|
||||||
def.setLeft(UnitConvertor(left, Unit::Mm, Unit::Px));
|
def.setLeft(UnitConvertor(m.left(), Unit::Mm, Unit::Px));
|
||||||
def.setRight(UnitConvertor(right, Unit::Mm, Unit::Px));
|
def.setRight(UnitConvertor(m.right(), Unit::Mm, Unit::Px));
|
||||||
def.setTop(UnitConvertor(top, Unit::Mm, Unit::Px));
|
def.setTop(UnitConvertor(m.top(), Unit::Mm, Unit::Px));
|
||||||
def.setBottom(UnitConvertor(bottom, Unit::Mm, Unit::Px));
|
def.setBottom(UnitConvertor(m.bottom(), Unit::Mm, Unit::Px));
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,15 +45,13 @@ TST_VPoster::TST_VPoster(QObject *parent) :
|
||||||
void TST_VPoster::BigPoster()
|
void TST_VPoster::BigPoster()
|
||||||
{
|
{
|
||||||
QPrinter printer;
|
QPrinter printer;
|
||||||
printer.setResolution(96);// By default
|
printer.setResolution(static_cast<int>(PrintDPI));// By default
|
||||||
printer.setPageSize(QPageSize(QPageSize::A4));
|
printer.setPageSize(QPageSize(QPageSize::A4));
|
||||||
printer.setFullPage(true);
|
printer.setFullPage(true);
|
||||||
// We need to set full page because otherwise QPrinter->pageRect returns different values in Windows and Linux
|
// We need to set full page because otherwise QPrinter->pageRect returns different values in Windows and Linux
|
||||||
|
|
||||||
//sets the margins to 0 to perform the test.
|
//sets the margins to 0 to perform the test.
|
||||||
const qreal left = 0, top = 0, right = 0, bottom = 0;
|
printer.setPageMargins(QMarginsF(), QPageLayout::Millimeter);
|
||||||
printer.setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Millimeter);
|
|
||||||
|
|
||||||
|
|
||||||
const QSize image(2622, 3178); // Little bit bigger than A1
|
const QSize image(2622, 3178); // Little bit bigger than A1
|
||||||
VPoster posterazor(&printer);
|
VPoster posterazor(&printer);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user