for (int i = 0; model->rowCount() > i; i++)
{
int x = model->data(model->index(i, 0), Qt::DisplayRole).toInt();
QString filename
= dir.
append(QDir::separator()).
append(model
->data
(model
->index
(i,
1), Qt
::DisplayRole).
toString()).
append(".pdf");
printer
->setOutputFormat
(QPrinter::PdfFormat);
printer
->setOrientation
(QPrinter::Portrait);
printer->setFullPage(true);
printer->setOutputFileName(filename);
QPrintPreviewWidget * printPreview = new QPrintPreviewWidget(printer, this);
Report * r = new Report(x, this); // Report generation class
connect(printPreview,
SIGNAL(paintRequested
(QPrinter*)), r,
SLOT(Print
(QPrinter*)));
printPreview->print();
disconnect
(printPreview,
SIGNAL(paintRequested
(QPrinter*)), r,
SLOT(Print
(QPrinter*)));
}
for (int i = 0; model->rowCount() > i; i++)
{
int x = model->data(model->index(i, 0), Qt::DisplayRole).toInt();
QString filename = dir.append(QDir::separator()).append(model->data(model->index(i, 1), Qt::DisplayRole).toString()).append(".pdf");
QPrinter * printer = new QPrinter(QPrinter::HighResolution);
printer->setOutputFormat(QPrinter::PdfFormat);
printer->setOrientation(QPrinter::Portrait);
printer->setPaperSize(QSizeF(210, 297), QPrinter::Millimeter);
printer->setFullPage(true);
printer->setOutputFileName(filename);
QPrintPreviewWidget * printPreview = new QPrintPreviewWidget(printer, this);
Report * r = new Report(x, this); // Report generation class
connect(printPreview, SIGNAL(paintRequested(QPrinter*)), r, SLOT(Print(QPrinter*)));
printPreview->print();
disconnect(printPreview, SIGNAL(paintRequested(QPrinter*)), r, SLOT(Print(QPrinter*)));
}
To copy to clipboard, switch view to plain text mode
Bookmarks