QPagedPaintDevice Class
QPagedPaintDevice 类表示一种支持多个页面的绘图设备。更多内容...
| 头文件: | #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 PDF 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()。
© 2026 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.