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:
#include <QCoreApplication>
#include <QPainter>
#include <QPrinter>
#include <QTextDocument>
#include <QTimer>
int main(int argc, char *argv[])
{
textDocument.
setPlainText(QString("some text"));
textDocument.print(&printer);
QTimer::singleShot(0,
&app,
SLOT(quit
()));
return app.exec();
}
#include <QCoreApplication>
#include <QPainter>
#include <QPrinter>
#include <QTextDocument>
#include <QTimer>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QPrinter printer;
QPainter painter(&printer);
QTextDocument textDocument;
textDocument.setPlainText(QString("some text"));
textDocument.print(&printer);
QTimer::singleShot(0, &app, SLOT(quit()));
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks