Consider this code:
void MainWindow
::print(QPrinter *printer
) {
textEdit[0].append("First Page");
textEdit[1].append("Second page");
textEdit[0].print(printer);
printer->newPage();
textEdit[1].print(printer);
}
void MainWindow::on_pushButton_clicked()
{
QPrintPreviewDialog preview(&printer,this);
preview.exec();
}
void MainWindow::print(QPrinter *printer)
{
QTextEdit textEdit[2];
textEdit[0].append("First Page");
textEdit[1].append("Second page");
textEdit[0].print(printer);
printer->newPage();
textEdit[1].print(printer);
}
void MainWindow::on_pushButton_clicked()
{
QPrinter printer(QPrinter::HighResolution);
QPrintPreviewDialog preview(&printer,this);
connect(&preview, SIGNAL(paintRequested(QPrinter*)),SLOT(print(QPrinter *)));
preview.exec();
}
To copy to clipboard, switch view to plain text mode
I get a single page print preview showing 'second page' and a page number '1' at the bottom. 
where did the first page go?
Bookmarks