How to duplex print?
-
I want to print with a duplex printer, but I want to print directly from code, without the printer dialog. I have Qt 5.4. From what I see there is no more a setDoubleSidedPrinting(), but my code still compile. I tried with setDoubleSidedPrinting(true) and also with setDuplex(QPrinter::DuplexAuto) but the printer doesn't print duplex. Maybe is the problem I write the pages: I have 2 pages and after the first page I call newPage().
@void printPage()
{
QPainter painter(m_printer);
making some settings
page.mainFrame()->render(&painter); // page is QWebPage
}void mainFunction()
{
printPage();
m_printer->newPage();
printPage();
}@ -
Hi,
I'm not sure I'm following you. Why would you need to set that ?
-
I updated the first post. I only want to print a double sided page/duplex directly/without using print dialog.
-
I updated the first post. I only want to print a double sided page/duplex directly/without using print dialog.
-
Did you check that you are trying to use the correct printer ?
-
Did you check that you are trying to use the correct printer ?
-
Yes, and I will make a check function for it. But the code is right?
-
Yes, and I will make a check function for it. But the code is right?
-
How do you create m_printer ?
-
How do you create m_printer ?
-
@m_printer = new QPrinter(QPrinter::HighResolution);
m_printer->setPageSize(QPageSize(QPageSize::A4));
m_printer->setOrientation(QPrinter::Portrait);
m_printer->setPageMargins(QMarginsF(20.f,20.f,10.f,10.f));@ -
@m_printer = new QPrinter(QPrinter::HighResolution);
m_printer->setPageSize(QPageSize(QPageSize::A4));
m_printer->setOrientation(QPrinter::Portrait);
m_printer->setPageMargins(QMarginsF(20.f,20.f,10.f,10.f));@ -
You should rather use the second constructor using QPrinterInfo to ensure you are using the right device
-
You should rather use the second constructor using QPrinterInfo to ensure you are using the right device