I can Screenshot from a QML component using grabToImage and use QPrinter to print that image,
I want to display that image fit to A4 paper page or print to center of A4 paper.
But the image is draw left of paper.
{
QImage img
= qvariant_cast<QImage>
(data
);
if(dlg
->exec
() == QDialog::Accepted) {
//painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
painter.
drawImage(QPoint(0,
0),img
);
printer.setFullPage(true);
painter.end();
}
}
void pr::print(QVariant data)
{
QImage img = qvariant_cast<QImage>(data);
QPrinter printer;
QPrintDialog *dlg = new QPrintDialog(&printer,0);
if(dlg->exec() == QDialog::Accepted) {
QPainter painter(&printer);
printer.setPageSize(QPrinter::A4);
//painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
painter.drawImage(QPoint(0,0),img);
printer.setFullPage(true);
painter.end();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks