Unfortunately I don't have physical printer on my machine at the moment, so I use PDFCreator virtual printer (http://www.pdfforge.org/products/pdfcreator). This makes it easy to test my printing application, but there are some problems unhappy
Order Form application from the set of standard Qt examples prints all its documents normal, but my application fails for some reason.
Here is source code of my application:
#include <QApplication>
#include <QPainter>
#include <QPrintDialog>
#include <QPrinter>
#include <QTextDocument>
#include <QTimer>
int main(int argc, char *argv[])
{
//QPrintDialog *dialog = new QPrintDialog(&printer);
//dialog->setWindowTitle("Print Document");
//if (dialog->exec() != QDialog::Accepted)
// return 0;
textDocument.setPlainText("hello");
textDocument.print(&printer);
QTimer::singleShot(0,
&app,
SLOT(quit
()));
return app.exec();
}
#include <QApplication>
#include <QPainter>
#include <QPrintDialog>
#include <QPrinter>
#include <QTextDocument>
#include <QTimer>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPrinter printer;
QPainter painter(&printer);
//QPrintDialog *dialog = new QPrintDialog(&printer);
//dialog->setWindowTitle("Print Document");
//if (dialog->exec() != QDialog::Accepted)
// return 0;
QTextDocument textDocument;
textDocument.setPlainText("hello");
textDocument.print(&printer);
QTimer::singleShot(0, &app, SLOT(quit()));
return app.exec();
}
To copy to clipboard, switch view to plain text mode
If I compile application with comments PDFCreate prints a blank page (without "hello" text). If I show QPrintDialog for setting by uncommenting four lines then nothing happens (even printing a blank page doesn't occur).
What is wrong? Thanks!
Qt 4.3.3
Windows XP SP2
Bookmarks