Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
errors.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QtWidgets>
5#include <QtPrintSupport/qtprintsupportglobal.h>
6#if QT_CONFIG(printdialog)
7#include <QPrinter>
8#endif
9
10int main(int argc, char **argv)
11{
12 QApplication app(argc, argv);
13
14//! [0]
15 QPrinter printer;
16 printer.setOutputFormat(QPrinter::PdfFormat);
17 printer.setOutputFileName("/foobar/nonwritable.pdf");
18 QPainter painter;
19 if (! painter.begin(&printer)) { // failed to open file
20 qWarning("failed to open file, is it writable?");
21 return 1;
22 }
23 painter.drawText(10, 10, "Test");
24 if (! printer.newPage()) {
25 qWarning("failed in flushing page to disk, disk full?");
26 return 1;
27 }
28 painter.drawText(10, 10, "Test 2");
29 painter.end();
30//! [0]
31 return 0;
32}
int main(int argc, char *argv[])
[ctor_close]