I'm trying to print some plain text in my small console application (which is listed below), but it doesnt work properly. When application starts, I see this error message:

QPainter::begin(): Returned false

... and then nothing happens.

I didn't find any useful with Google unhappy

I'm using Qt 4.3.3 under Windows XP SP2

Standard "Rich Text/Order Form" example prints documents finely, but I don't know why it doesnt work in my program.

Wherein can be the problem?

Thanks.

Source:

Qt Code:
  1. #include <QCoreApplication>
  2.  
  3. #include <QPainter>
  4. #include <QPrinter>
  5. #include <QTextDocument>
  6. #include <QTimer>
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10. QCoreApplication app(argc, argv);
  11.  
  12. QPrinter printer;
  13. QPainter painter(&printer);
  14.  
  15. QTextDocument textDocument;
  16. textDocument.setPlainText(QString("some text"));
  17. textDocument.print(&printer);
  18.  
  19. QTimer::singleShot(0, &app, SLOT(quit()));
  20. return app.exec();
  21. }
To copy to clipboard, switch view to plain text mode