PDA

View Full Version : QPrinter and QPrintDialog



Alexander111122
29th March 2016, 11:16
Greetings everyone!
I have posted a problem in this thread:
http://www.qtcentre.org/threads/65534-QPrinter-and-QPrintDialog
I have succesfully dealed with the first problem with help from anda_skoa. For which I wish to send him many thanks.
But now I have another one wich is bothering me:
I have no idea why, but QPrintPreviewDialog is showing me that it wants to print two pages, though it renders my widget only on one page, so the second is empty.
Second of all - my mainwindow widget is rendered correctly only when the app is in fullscreen mode. When the app is in window mode - I can see only part of my mainwidget put onto the page to be printed.


connect(prev_dialog, SIGNAL(paintRequested(QPrinter*)), this, SLOT(print_preview()));
connect(ui->actionPrint_Preview, SIGNAL(triggered(bool)), this, SLOT(preview_called()));
//////////////////////////////////////////////////////////////////////////////////////////
void MainWindow::print_preview(void)
{
QPainter painter(&printer);
painter.setWindow(this->geometry());

this->render(&painter);
printer.newPage();
/*if (prev_dialog->exec() == QDialog::Accepted)
{

}*/
}

void MainWindow::preview_called(void)
{
prev_dialog->exec();
}

11836
11835