Solved Print two separate pages
-
I have two pages that I want to print
Now I can print them separately by calling the printer and the painter twice,
But I want to call the printer once, and print them
How can I do it?QPixmap pix =ui->stackedWidget->widget(0)->grab(); QPrinter printer(QPrinter::HighResolution); printer.setOrientation(QPrinter::Landscape); QPainter painter; painter.begin(&printer); double xscale = printer.pageRect().width() / double(pix.width()); double yscale = printer.pageRect().height() / double(pix.height()); double scale = qMin(xscale, yscale); painter.translate(printer.paperRect().x() + printer.pageRect().width() / 2, printer.paperRect().y() + printer.pageRect().height() / 2); painter.scale(scale, scale); painter.translate(-width() / 2, -height() / 2); painter.drawPixmap(0, 0, pix); painter.end();
QPrinter printer; QPrintDialog dlg(&printer, 0); if (dlg.exec() == QDialog::Accepted) { // Output chart as QImage /// do some thing // Print the image QPainter painter(&printer); painter.drawImage(QPoint(80,0),image); painter.end(); }
-
Hi,
Is QPrinter::newPage what you are looking for ?
-
@sgaist It's work tnx
painter.drawPixmap(0, 0, pix); printer.newPage(); painter.drawImage(QPoint(80,0),image); }
-
@sgaist I have another problem
the page has scrollBar
When I grab ItQPixmap pix = ui-> stackedWidget-> widget (0) -> grab ();
, Prints half of the page
How do I print the entire page?? -
What kind of widget is that ?
-
a page? do you mean a widget?
-
@sgaist
I want to print a page of the stack widget that has the scroll bar
This page contains line Edit, Push Button
It's solve with :QPixmap pix = ui->scrollAreaWidgetContents->grab();