Hello together,
I like to print one page of multiple pages. But the printer allways prints all pages.
What I'm doing wrong?
Please have a look at the source.
void CPrintWorkout::print(){
QPrinter printer(QPrinter::ScreenResolution);
printer.setPageSize(QPrinter::A4);
printer.setOrientation(QPrinter::Landscape);
QPrintPreviewDialog preview(&printer);
connect(&preview, SIGNAL(paintRequested(QPrinter*)), SLOT(print(QPrinter*)));
preview.exec();
}
// ** SLOTS **
void CPrintWorkout::print(QPrinter *printer){
printer->setPageOrder(QPrinter::FirstPageFirst);
QPainter painter;
painter.begin(printer);
QTextDocument doc;
doc.setTextWidth(printer->pageRect().width());
for(int i = 1; i <= 3; i++){
doc.setHtml(QString::number(i) + ". Page");
doc.drawContents(&painter);
if(i < 3) printer->newPage();
}
painter.end();
}
Thank you very much.
kea_
Bookmarks