Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
24 printer.setOutputFileName("print.ps");
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();
38 qApp->quit();
39}
\inmodule QtCore
Definition qobject.h:103
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
bool begin(QPaintDevice *)
Begins painting the paint device and returns true if successful; otherwise returns false.
bool end()
Ends painting.
\reentrant
Definition qprinter.h:28
@ HighResolution
Definition qprinter.h:31
#define qApp
QByteArray page
[45]
QPainter painter(this)
[7]