QPagedPaintDevice Class
QPagedPaintDevice 类表示支持多页面的油漆设备。更多
Header: | #include <QPagedPaintDevice> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
继承: | QPaintDevice |
继承于 |
- 所有成员的列表,包括继承成员
- QPagedPaintDevice 属于绘画类。
公共类型
enum | PdfVersion { PdfVersion_1_4, PdfVersion_A1b, PdfVersion_1_6, PdfVersion_X4 } |
公共函数
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) |
详细说明
分页绘画设备用于生成用于打印或 PDF 等格式的输出。QPdfWriter 和QPrinter 继承自它。
成员类型文档
enum QPagedPaintDevice::PdfVersion
PdfVersion 枚举描述了由QPrinter 或QPdfWriter 生成的 PDF 文件的版本。
常量 | 值 | 描述 |
---|---|---|
QPagedPaintDevice::PdfVersion_1_4 | 0 | 生成与 PDF 1.4 兼容的文件。 |
QPagedPaintDevice::PdfVersion_A1b | 1 | 生成 PDF/A-1b 兼容文档。 |
QPagedPaintDevice::PdfVersion_1_6 | 2 | 生成 PDF 1.6 兼容文档。此值在 Qt 5.12 中添加。 |
QPagedPaintDevice::PdfVersion_X4 (since Qt 6.8) | 3 | 生成 PDF/X-4 兼容文档。 |
成员函数文档
[virtual noexcept]
QPagedPaintDevice::~QPagedPaintDevice()
销毁对象。
[pure virtual]
bool QPagedPaintDevice::newPage()
开始一个新页面。成功时返回true
。
QPageLayout QPagedPaintDevice::pageLayout() const
返回当前页面布局。使用该方法可访问当前的QPageSize,QPageLayout::Orientation,QMarginsF, fullRect() 和 paintRect()。
请注意,您不能在返回的对象上使用设置器,您必须调用QPagedPaintDevice 的各个设置器或使用setPageLayout()。
另请参见 setPageLayout()、setPageSize()、setPageOrientation() 和setPageMargins()。
[since 6.0]
QPageRanges QPagedPaintDevice::pageRanges() const
返回与此设备相关的页面范围。
此函数在 Qt 6.0 中引入。
另请参阅 setPageRanges(),QPageRanges,QPrinter::fromPage() 和QPrinter::toPage() 。
[virtual]
bool QPagedPaintDevice::setPageLayout(const QPageLayout &newPageLayout)
将页面布局设置为newPageLayout 。
应在调用QPainter::begin() 之前,或在调用newPage() 将新的页面布局应用到新页面之前立即调用此方法。在调用 setPageLayout() 和newPage() 之间不应调用任何绘制方法,因为可能会使用错误的绘制指标。
如果页面布局已成功设置为newPageLayout ,则返回 true。
另请参阅 pageLayout()。
[virtual]
bool QPagedPaintDevice::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units = QPageLayout::Millimeter)
设置给定units 中定义的页面margins 。
应在调用QPainter::begin() 之前调用,或在调用newPage() 将新页边距应用到新页面之前立即调用。在调用 setPageMargins() 和newPage() 之间不应调用任何绘制方法,因为可能会使用错误的绘制指标。
要获取当前页面页边距,请使用pageLayout().margins().
如果页面边距已成功设置为margins ,则返回 true。
另请参见 pageLayout()。
[virtual]
bool QPagedPaintDevice::setPageOrientation(QPageLayout::Orientation orientation)
设置页面orientation 。
页面方向用于在获取页面矩形时定义页面大小的方向。
应在调用QPainter::begin() 之前调用,或在调用newPage() 将新方向应用到新页面之前立即调用。在调用 setPageOrientation() 和newPage() 之间不应调用任何绘制方法,因为可能会使用错误的绘制指标。
要获取当前QPageLayout::Orientation ,请使用pageLayout().orientation().
如果页面方向已成功设置为orientation ,则返回 true。
另请参阅 pageLayout()。
[virtual, since 6.0]
void QPagedPaintDevice::setPageRanges(const QPageRanges &ranges)
将此设备的页面范围设置为ranges 。
此函数在 Qt 6.0 中引入。
另请参阅 pageRanges() 。
[virtual]
bool QPagedPaintDevice::setPageSize(const QPageSize &pageSize)
将页面大小设置为pageSize 。
要获取当前的QPageSize ,请使用pageLayout().pageSize() 。
在调用QPainter::begin() 之前,或在调用newPage() 将新的页面大小应用到新页面之前,应立即调用该方法。在调用 setPageSize() 和newPage() 之间不应调用任何绘制方法,因为可能会使用错误的绘制指标。
如果页面大小已成功设置为pageSize ,则返回 true。
另请参阅 pageLayout()。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.