QPagedPaintDevice Class

The QPagedPaintDevice class represents a paint device that supports multiple pages. More...

Header: #include <QPagedPaintDevice>
CMake: find_package(Qt6 COMPONENTS Gui REQUIRED) target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
Inherits: QPaintDevice
Inherited By:

QPdfWriter and QPrinter

Public Types

enum PdfVersion { PdfVersion_1_4, PdfVersion_A1b, PdfVersion_1_6 }

Public Functions

virtual ~QPagedPaintDevice()
virtual bool newPage() = 0
QPageLayout pageLayout() const
QPageRanges pageRanges() const
virtual bool setPageLayout(const QPageLayout &newPageLayout)
virtual bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units = QPageLayout::Millimeter)
virtual bool setPageOrientation(QPageLayout::Orientation orientation)
virtual void setPageRanges(const QPageRanges &ranges)
virtual bool setPageSize(const QPageSize &pageSize)

Detailed Description

Paged paint devices are used to generate output for printing or for formats like PDF. QPdfWriter and QPrinter inherit from it.

Member Type Documentation

enum QPagedPaintDevice::PdfVersion

The PdfVersion enum describes the version of the PDF file that is produced by QPrinter or QPdfWriter.

Constant Value Description
QPagedPaintDevice::PdfVersion_1_4 0 A PDF 1.4 compatible document is produced.
QPagedPaintDevice::PdfVersion_A1b 1 A PDF/A-1b compatible document is produced.
QPagedPaintDevice::PdfVersion_1_6 2 A PDF 1.6 compatible document is produced. This value was added in Qt 5.12.

Member Function Documentation

[virtual] QPagedPaintDevice::~QPagedPaintDevice()

Destroys the object.

[pure virtual] bool QPagedPaintDevice::newPage()

Starts a new page. Returns true on success.

[since 5.3] QPageLayout QPagedPaintDevice::pageLayout() const

Returns the current page layout. Use this method to access the current QPageSize, QPageLayout::Orientation, QMarginsF, fullRect() and paintRect().

Note that you cannot use the setters on the returned object, you must either call the individual QPagedPaintDevice setters or use setPageLayout().

This function was introduced in Qt 5.3.

See also setPageLayout(), setPageSize(), setPageOrientation(), and setPageMargins().

[since 6.0] QPageRanges QPagedPaintDevice::pageRanges() const

Returns the page ranges associated with this device.

This function was introduced in Qt 6.0.

See also setPageRanges(), QPageRanges, QPrinter::fromPage(), and QPrinter::toPage().

[virtual, since 5.3] bool QPagedPaintDevice::setPageLayout(const QPageLayout &newPageLayout)

Sets the page layout to newPageLayout.

You should call this before calling QPainter::begin(), or immediately before calling newPage() to apply the new page layout to a new page. You should not call any painting methods between a call to setPageLayout() and newPage() as the wrong paint metrics may be used.

Returns true if the page layout was successfully set to newPageLayout.

This function was introduced in Qt 5.3.

See also pageLayout().

[virtual, since 5.3] bool QPagedPaintDevice::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units = QPageLayout::Millimeter)

Set the page margins defined in the given units.

You should call this before calling QPainter::begin(), or immediately before calling newPage() to apply the new margins to a new page. You should not call any painting methods between a call to setPageMargins() and newPage() as the wrong paint metrics may be used.

To get the current page margins use pageLayout().margins().

Returns true if the page margins were successfully set to margins.

This function was introduced in Qt 5.3.

See also pageLayout().

[virtual, since 5.3] bool QPagedPaintDevice::setPageOrientation(QPageLayout::Orientation orientation)

Sets the page orientation.

The page orientation is used to define the orientation of the page size when obtaining the page rect.

You should call this before calling QPainter::begin(), or immediately before calling newPage() to apply the new orientation to a new page. You should not call any painting methods between a call to setPageOrientation() and newPage() as the wrong paint metrics may be used.

To get the current QPageLayout::Orientation use pageLayout().orientation().

Returns true if the page orientation was successfully set to orientation.

This function was introduced in Qt 5.3.

See also pageLayout().

[virtual, since 6.0] void QPagedPaintDevice::setPageRanges(const QPageRanges &ranges)

Sets the page ranges for this device to ranges.

This function was introduced in Qt 6.0.

See also pageRanges().

[virtual, since 5.3] bool QPagedPaintDevice::setPageSize(const QPageSize &pageSize)

Sets the page size to pageSize.

To get the current QPageSize use pageLayout().pageSize().

You should call this before calling QPainter::begin(), or immediately before calling newPage() to apply the new page size to a new page. You should not call any painting methods between a call to setPageSize() and newPage() as the wrong paint metrics may be used.

Returns true if the page size was successfully set to pageSize.

This function was introduced in Qt 5.3.

See also pageLayout().

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.0/qpagedpaintdevice.html