Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void MainWindow::on_print_clicked()
- {
- if (template_ptr != Q_NULLPTR) {
- QPrinter printer(QPrinter::HighResolution);
- if (QPrintDialog(&printer, this).exec() == QDialog::Accepted) {
- if (QPageSetupDialog(&printer, this).exec() == QDialog::Accepted) {
- QPainter painter(&printer);
- painter.setRenderHint(QPainter::Antialiasing);
- painter.setRenderHint(QPainter::TextAntialiasing);
- qreal x, _y, h, w, fake;
- ui->graphicsView->sceneRect().getRect(&x, &_y, &w, &fake);
- h = template_ptr->page_height*2.0;
- qint32 page = 0;
- while (true) {
- qreal y = _y + h*page;
- QRectF leftRect(x, y, w, template_ptr->page_height*2.0*5.0 - h*page);
- if (ui->graphicsView->scene()->items(leftRect).length() <= 0) {
- break;
- }
- QRectF sourceRect(x, y, w, h);
- ui->graphicsView->scene()->render(&painter, printer.pageRect(), sourceRect);
- printer.newPage();
- page++;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment