Help with printing Qpixmap
-
i want to print out Qtableview in QPrintPreviewDialog and this is my code .
but in QPrintPreviewDialog it show very small
"picture of my QPrintPreviewDialog ":http://www.xum.ir/images/2014/05/22/print.png
any body can help me?
@
void Report::filePrintPreview(){
#ifndef QT_NO_PRINTER
QPrinter printer(QPrinter::HighResolution);
QPrintPreviewDialog preview(&printer, this);
preview.setWindowFlags ( Qt::Window );
connect(&preview, SIGNAL(paintRequested(QPrinter*)), SLOT(printPreview(QPrinter *)));
preview.exec();
#endif
}void Report::printPreview(QPrinter *printer){
QPixmap pixmap(ui->tableView->size());
ui->tableView->render(&pixmap);
QPainter painter;
painter.begin(printer);//p is my QPrinter
printer->paintEngine()->drawPixmap(QRectF(0, 0, pixmap.width(), pixmap.height()), pixmap, QRectF(0, 0,pixmap.width(), pixmap.height()));
painter.end();
}
@ -
any body can't help me?
pleeeeeas -
Hi,
Have a look "here":http://qt-project.org/doc/qt-5/qtprintsupport-index.html#printing-widgets
-
[quote author="SGaist" date="1400794409"]Hi,
Have a look "here":http://qt-project.org/doc/qt-5/qtprintsupport-index.html#printing-widgets[/quote]
I've read this before,
If possible, read and then answer a question. -
No one could answer my question?