PDA

View Full Version : Qt 4.4.0 Problem with QPrintPreviewDialog



ad5xj
29th May 2008, 21:08
I am having a problem with the new QPrintPreviewDialog. The widget will display but the document I am printing will not. The display area is only gray.

Environment: XP Home SP2 MinGW and Qt 4.4.0 coding in eclipse

Here is some code snippets. Please help:



QPrinter *printer = new QPrinter;
printer->setOutputFormat(QPrinter::NativeFormat);
printer->setPaperSize(QPrinter::Letter);
printer->setOrientation(QPrinter::Landscape);

QPrintPreviewDialog *dlg = new QPrintPreviewDialog(printer, this);
connect(dlg, SIGNAL(paintRequested(devPrint)), this, SLOT(slotPrintLog(devPrint)));
dlg->setWindowModality(Qt::ApplicationModal);
dlg->setModal(true);
dlg->setWindowTitle(QString("Session Log Report Preview"));
textEdit->document()->print(printer);
dlg->exec();


===== code from slotPrintLog()=====


formatReport();
textEdit->print(devPrint);

========== code from formatReport()=======


// Create the first document cursor
QTextCursor cursor(textEdit->document());
. . . code to print report. . . .
.
.
.
cursor.format. . . and cursor.insertText . . . etc.
textEdit->documentEnd();

Any ideas?

There is precious little documentation on this new widget and the dialog. The examples are minimal at best. I need some new ideas.

mazurekwrc
30th May 2008, 10:30
this connect won't work


connect( dlg, SIGNAL( paintRequested( devPrint ) ), this, SLOT( slotPrintLog( devPrint ) ) );

you put value to signal and slot functions

ad5xj
30th May 2008, 15:01
That got it. Thanks!