[Qt-interest] QPrintPreviewDialog question
Steven Doerfler
sgd-qt at lugaru.com
Tue Mar 9 23:05:36 CET 2010
On 3/9/2010 1:39 PM, Robert Wood wrote:
> I'm trying to print a little form I have designed. It's a form with a
> QTextEdit placed on it; the QTextEdit is called "editor" and I have
> populated it on-the-fly following one of the nice little supplied
> examples and it looks grand.
>
> I have invoked the QPrintPreviewDialog as follows:
>
> QPrinter printer(QPrinter::HighResolution);
> QPrintPreviewDialog ppd(&printer,ui->editor,Qt::Window);
> ppd.exec();
>
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
Steven
More information about the Qt-interest-old
mailing list