[Qt-interest] QPrintPreviewDialog question
Robert Wood
robert.wood at apostrophe.co.uk
Tue Mar 9 23:47:26 CET 2010
On 09/03/10 22:05, Steven Doerfler wrote:
> The second parameter should be the dialog's parent window, such as your
> main window, not what to print. You tell the preview what to show by
> connecting a slot to the paintRequested() signal, as explained in the
> documentation.
>
> Here's some sample code for using a QTextEdit with print preview:
> http://doc.qt.nokia.com/4.6/demos-textedit-textedit-cpp.html
Thanks, Steven.
Yep, I did see this and I did try:
QPrinter printer(QPrinter::HighResolution);
QPrintPreviewDialog ppd(&printer,this,Qt::Window);
connect(&ppd, SIGNAL(paintRequested(QPrinter *)),
SLOT(printPreview(QPrinter *)));
ppd.exec();
Then had a little routine:
void invoice_dialogue::printPreview(QPrinter *printer)
{
ui->editor->print(printer);
}
However, this never gets called. I must be missing something vital here
and I must confess I don't understand this paintRequested signal. The
documentation says that the signal is emitted when the
QPrintPreviewDialog needs to generate a set of preview pages. I am
assuming that this should get called when the ppd.exec launches the
dialogue. The dialogue says it's page 1 of 0, so there's obviously some
step I am missing and/or failing to understand.
Cheers,
Rob
More information about the Qt-interest-old
mailing list