QPrintEngine Class

QPrintEngine 类定义了QPrinter 与特定打印子系统交互的接口。更多

头文件: #include <QPrintEngine>
CMake: find_package(Qt6 REQUIRED COMPONENTS PrintSupport)
target_link_libraries(mytarget PRIVATE Qt6::PrintSupport)
qmake: QT += printsupport

注意:该类中的所有函数都是可重入的

公共类型

enum PrintEnginePropertyKey { PPK_CollateCopies, PPK_ColorMode, PPK_Creator, PPK_Duplex, PPK_DocumentName, …, PPK_CustomBase }

公共函数

virtual ~QPrintEngine()
virtual bool abort() = 0
virtual int metric(QPaintDevice::PaintDeviceMetric id) const = 0
virtual bool newPage() = 0
virtual QPrinter::PrinterState printerState() const = 0
virtual QVariant property(QPrintEngine::PrintEnginePropertyKey key) const = 0
virtual void setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value) = 0

详细说明

创建自己的打印引擎时,常见的情况是同时派生自QPaintEngine 和 QPrintEngine。打印引擎的各种属性用property() 给出,用setProperty() 设置。

另请参阅 QPaintEngine

成员类型文档

enum QPrintEngine::PrintEnginePropertyKey

该枚举用于在打印引擎和QPrinter 之间传递属性。特定打印引擎可能支持也可能不支持某个属性。

常量说明
QPrintEngine::PPK_CollateCopies0布尔值,表示打印输出是否应进行拼版。
QPrintEngine::PPK_ColorMode1QPrinter::ColorMode ,彩色或单色。
QPrintEngine::PPK_Creator2描述文档创建者的字符串。
QPrintEngine::PPK_Duplex20一个布尔值,用于指示打印输出是否应双面使用打印纸。
QPrintEngine::PPK_DocumentName3描述 Spooler 中文档名称的字符串。
QPrintEngine::PPK_FontEmbedding19一个布尔值,用于指示是否将文档字体数据嵌入发送到打印机的数据中。
QPrintEngine::PPK_FullPage4布尔值,用于说明打印机是否应全页打印。
QPrintEngine::PPK_NumberOfCopies5过时。指定副本数量的整数。使用 PPK_CopyCount 代替。
QPrintEngine::PPK_Orientation6指定QPageLayout::Orientation 值。
QPrintEngine::PPK_OutputFileName7字符串形式的输出文件名。空文件名表示打印机不应打印到文件。
QPrintEngine::PPK_PageOrder8指定QPrinter::PageOrder 值。
QPrintEngine::PPK_PageRect9指定页面矩形的QRect
QPrintEngine::PPK_PageSize10已过时。使用 PPK_PaperSize 代替。
QPrintEngine::PPK_PaperRect11指定纸张矩形的QRect
QPrintEngine::PPK_PaperSource12指定一个QPrinter::PaperSource 值。
QPrintEngine::PPK_PaperSources21指定多个QPrinter::PaperSource 值。
QPrintEngine::PPK_PaperName26指定纸张名称的字符串。
QPrintEngine::PPK_PaperSizePPK_PageSize指定一个 QPrinter::PaperSize 值。
QPrintEngine::PPK_PrinterName13指定打印机名称的字符串。
QPrintEngine::PPK_PrinterProgram14指定用于打印的打印机程序名称的字符串、
QPrintEngine::PPK_Resolution15描述该打印机每英寸点数的整数。
QPrintEngine::PPK_SelectionOption16
QPrintEngine::PPK_SupportedResolutions17描述打印机支持的分辨率集的整数 QVariants 列表。
QPrintEngine::PPK_WindowsPageSize18指定 Windows 上 DM_PAPER 项的整数。
QPrintEngine::PPK_CustomPaperSize22QSizeF 指定QPrinter::Point 单位中的自定义纸张尺寸。
QPrintEngine::PPK_PageMargins23一个QList<QVariant>,包含以QPrinter::Point 为单位的左、上、右和下页边距值。
QPrintEngine::PPK_CopyCount24一个整数,指定要打印的份数。
QPrintEngine::PPK_SupportsMultipleCopies25一个布尔值,表示打印机是否支持在一个任务中打印多份。
QPrintEngine::PPK_QPageSize27使用QPageSize 对象设置页面大小。
QPrintEngine::PPK_QPageMargins28使用QMarginsFQPageLayout::Unit 的 std::pair 设置页边距。
QPrintEngine::PPK_QPageLayout29使用QPageLayout 对象设置页面布局。
QPrintEngine::PPK_CustomBase0xff00扩展的基础。

成员函数文档

[virtual noexcept] QPrintEngine::~QPrintEngine()

销毁打印引擎。

[pure virtual] bool QPrintEngine::abort()

指示打印引擎终止打印过程。如果成功则返回 true,否则返回false

[pure virtual] int QPrintEngine::metric(QPaintDevice::PaintDeviceMetric id) const

返回给定id 的度量值。

[pure virtual] bool QPrintEngine::newPage()

指示打印引擎开始打印新页面。如果打印机能够创建新页面,则返回true ;否则返回false

[pure virtual] QPrinter::PrinterState QPrintEngine::printerState() const

返回打印引擎正在使用的打印机的当前状态。

[pure virtual] QVariant QPrintEngine::property(QPrintEngine::PrintEnginePropertyKey key) const

返回key 指定的打印引擎属性。

另请参阅 setProperty()。

[pure virtual] void QPrintEngine::setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value)

key 指定的打印引擎属性设置为给定的value

另请参阅 property() 。

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