QPagedPaintDevice Class

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

Header: #include <QPagedPaintDevice>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
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, PdfVersion_X4 }

Public Functions

virtual ~QPagedPaintDevice()
virtual bool newPage() = 0
QPageLayout pageLayout() const
(since 6.0) 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)
(since 6.0) 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.

ConstantValueDescription
QPagedPaintDevice::PdfVersion_1_40A PDF 1.4 compatible document is produced.
QPagedPaintDevice::PdfVersion_A1b1A PDF/A-1b compatible document is produced.
QPagedPaintDevice::PdfVersion_1_62A PDF 1.6 compatible document is produced. This value was added in Qt 5.12.
QPagedPaintDevice::PdfVersion_X4 (since Qt 6.8)3A PDF/X-4 compatible document is produced.

Member Function Documentation

[virtual noexcept] QPagedPaintDevice::~QPagedPaintDevice()

Destroys the object.

[pure virtual] bool QPagedPaintDevice::newPage()

Starts a new page. Returns true on success.

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().

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] 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.

See also pageLayout().

[virtual] 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.

See also pageLayout().

[virtual] 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.

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] 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.

See also pageLayout().