blob: 55f78e8717c6198af0c2e2f49a538eb5f0d60392 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include <QtGui>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
//! [0]
QPrinter printer;
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName("/foobar/nonwritable.pdf");
QPainter painter;
if (! painter.begin(&printer)) { // failed to open file
qWarning("failed to open file, is it writable?");
return 1;
}
painter.drawText(10, 10, "Test");
if (! printer.newPage()) {
qWarning("failed in flushing page to disk, disk full?");
return 1;
}
painter.drawText(10, 10, "Test 2");
painter.end();
//! [0]
return 0;
}
|