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
object.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 "object.h"
5
6#include <QtWidgets>
7#include <QtPrintSupport/qtprintsupportglobal.h>
8#if QT_CONFIG(printdialog)
9#include <QPrinter>
10#endif
11
12Object::Object(QObject *parent)
13 : QObject(parent)
14{
15}
16
17void Object::print()
18{
19 int numberOfPages = 10;
20 int lastPage = numberOfPages - 1;
21
22//! [0]
23 QPrinter printer(QPrinter::HighResolution);
24 printer.setOutputFileName("print.ps");
25 QPainter painter;
26 painter.begin(&printer);
27
28 for (int page = 0; page < numberOfPages; ++page) {
29
30 // Use the painter to draw on the page.
31
32 if (page != lastPage)
33 printer.newPage();
34 }
35
36 painter.end();
37//! [0]
38 qApp->quit();
39}