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.
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.