QPixmap and printer resolution
I want to print a pixmap with high resolution. Unfortunately, when i make QPrinter p(QPrinter::highResolution) or (QPrinter::printerResolution) the pixmap is too small on the paper. Has someone a idea?
My code:
QPrinter p;
QPrintDialog qp (&p, this);
if (qp.exec() == QDialog::Accepted)
{
qDebug () << "printerDialog";
QRect rect (0, 0, 288, 180);
QPixmap qpm = QPixmap::grabWidget(cardWidget, rect);
QPainter painter;
qpm.scaled(p.pageRect().width(), p.pageRect().height(), Qt::KeepAspectRatio);
painter.begin (&p);
painter.drawPixmap (0, 0, qpm);
painter.end();
}
Thanks a lot.
Re: QPixmap and printer resolution
Override the resolution with QPrinter::setResolution( int dpi ).
You can use 720 dpi, and should result in a good picture quality.
Also, be careful when scaling the pixmaps, because the process is not lossless.
Regards
Re: QPixmap and printer resolution
It's too late, but just to notice, you should use:
Code:
qmp = qpm.scaled(p.pageRect().width(), p.pageRect().height(), Qt::KeepAspectRatio);
instead of:
Code:
qpm.scaled(p.pageRect().width(), p.pageRect().height(), Qt::KeepAspectRatio);
Otherwise your qpixmap won't be rescaled!
Regards,
Oscar