void MainWindow::printPreview(){
QPrintPreviewDialog preview(&print,this);
connect(&preview,
SIGNAL(paintRequested
(QPrinter *)),
SLOT(printPreview
(QPrinter*)));
preview.exec();
}
...
void MainWindow
::printPreview(QPrinter* p
){ printReport(p,0);
}
void MainWindow::printPreview(){
QPrinter print(QPrinter::HighResolution);
print.setPaperSize(QPrinter::A4);
print.setPageSize(QPrinter::A4);
QPrintPreviewDialog preview(&print,this);
connect(&preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printPreview(QPrinter*)));
preview.exec();
}
...
void MainWindow::printPreview(QPrinter* p){
printReport(p,0);
}
To copy to clipboard, switch view to plain text mode
In printPreview there is a call to a method in a class:
...
m_document->setPageSize(printer->pageRect().size());
...
QString site
=" <table bgcolor=\"lightGray\" border=\"0\"><tbody><tr ><td width=\"800\">" + QObject::tr("Sito") +"</td></tr></tbody> </table>";
m_cursor.insertHtml(site);
m_cursor.
insertText(QObject::tr("Sito"),boldFormat
);
int pw = printer->pageRect().width();
int ph =printer->pageRect().height();
p.begin(printer);
p.save();
m_document->adjustSize();
QTransform tra;
tra.scale(11,11);
p.setTransform(tra);
...
m_document->drawContents(&p,printer->paperRect());
p.restore();
p.end();
...
m_document->setPageSize(printer->pageRect().size());
...
QString site =" <table bgcolor=\"lightGray\" border=\"0\"><tbody><tr ><td width=\"800\">" + QObject::tr("Sito") +"</td></tr></tbody> </table>";
m_cursor.insertHtml(site);
m_cursor.insertText(QObject::tr("Sito"),boldFormat);
m_cursor.movePosition(QTextCursor::EndOfBlock);
QPainter p;
int pw = printer->pageRect().width();
int ph =printer->pageRect().height();
p.begin(printer);
p.save();
m_document->adjustSize();
QTransform tra;
tra.scale(11,11);
p.setTransform(tra);
...
m_document->drawContents(&p,printer->paperRect());
p.restore();
p.end();
To copy to clipboard, switch view to plain text mode
Bookmarks