QPrinterInfo Class
QPrinterInfo 类提供了对现有打印机信息的访问。更多
头文件: | #include <QPrinterInfo> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS PrintSupport) target_link_libraries(mytarget PRIVATE Qt6::PrintSupport) |
qmake: | QT += printsupport |
- 所有成员(包括继承成员)的列表
- QPrinterInfo 是打印机和打印 API 的一部分。
公共函数
QPrinterInfo() | |
QPrinterInfo(const QPrinter &printer) | |
QPrinterInfo(const QPrinterInfo &other) | |
~QPrinterInfo() | |
QPrinter::ColorMode | defaultColorMode() const |
QPrinter::DuplexMode | defaultDuplexMode() const |
QPageSize | defaultPageSize() const |
QString | description() const |
bool | isDefault() const |
bool | isNull() const |
bool | isRemote() const |
QString | location() const |
QString | makeAndModel() const |
QPageSize | maximumPhysicalPageSize() const |
QPageSize | minimumPhysicalPageSize() const |
QString | printerName() const |
QPrinter::PrinterState | state() const |
QList<QPrinter::ColorMode> | supportedColorModes() const |
QList<QPrinter::DuplexMode> | supportedDuplexModes() const |
QList<QPageSize> | supportedPageSizes() const |
QList<int> | supportedResolutions() const |
bool | supportsCustomPageSizes() const |
QPrinterInfo & | operator=(const QPrinterInfo &other) |
静态公共成员
QStringList | availablePrinterNames() |
QList<QPrinterInfo> | availablePrinters() |
QPrinterInfo | defaultPrinter() |
QString | defaultPrinterName() |
QPrinterInfo | printerInfo(const QString &printerName) |
成员函数文档
QPrinterInfo::QPrinterInfo()
构造一个空的 QPrinterInfo 对象。
另请参阅 isNull().
[explicit]
QPrinterInfo::QPrinterInfo(const QPrinter &printer)
从printer 构造一个 QPrinterInfo 对象。
QPrinterInfo::QPrinterInfo(const QPrinterInfo &other)
构造other 的副本。
[noexcept]
QPrinterInfo::~QPrinterInfo()
销毁QPrinterInfo 对象。对象中的值引用将失效。
[static]
QStringList QPrinterInfo::availablePrinterNames()
返回系统中所有可用打印机名称的列表。
建议使用该列表而不是availablePrinters() ,因为在大多数系统中使用该列表速度更快。
请注意,如果本地系统或远程打印服务器发生更改,列表可能会过时。只有在需要时才实例化所需的QPrinterInfo 实例,并始终在调用前检查其有效性。
[static]
QList<QPrinterInfo> QPrinterInfo::availablePrinters()
返回本系统所有可用打印机的QPrinterInfo 对象列表。
不建议使用此方法,因为创建每个打印机实例可能需要很长时间,尤其是在有远程联网打印机的情况下,而且如果本地系统或远程打印服务器上有更改,保留的实例可能会过时。请使用availablePrinterNames() 并仅在需要时实例化打印机实例。
QPrinter::ColorMode QPrinterInfo::defaultColorMode() const
返回打印机的默认颜色模式。
QPrinter::DuplexMode QPrinterInfo::defaultDuplexMode() const
返回打印机的默认双面模式。
QPageSize QPrinterInfo::defaultPageSize() const
返回该打印机当前的默认页面尺寸。
[static]
QPrinterInfo QPrinterInfo::defaultPrinter()
返回系统默认打印机。
在使用前应使用isNull() 检查返回值,以防没有默认打印机。
在某些系统中,可能存在可用的打印机,但没有一台被设置为默认打印机。
另请参阅 isNull()、isDefault() 和availablePrinters()。
[static]
QString QPrinterInfo::defaultPrinterName()
返回当前默认打印机名称。
QString QPrinterInfo::description() const
返回打印机的人可读描述。
另请参阅 QPrinterInfo::printerName()。
bool QPrinterInfo::isDefault() const
返回该打印机当前是否为默认打印机。
bool QPrinterInfo::isNull() const
返回QPrinterInfo 对象是否包含打印机定义。
空的QPrinterInfo 对象可能是在系统中没有打印机的情况下调用defaultPrinter() 的结果。
bool QPrinterInfo::isRemote() const
返回该打印机是否为远程网络打印机。
QString QPrinterInfo::location() const
返回打印机的可读位置。
QString QPrinterInfo::makeAndModel() const
返回打印机的可读品牌和型号。
QPageSize QPrinterInfo::maximumPhysicalPageSize() const
返回打印机支持的最大物理页面尺寸。
另请参阅 minimumPhysicalPageSize()。
QPageSize QPrinterInfo::minimumPhysicalPageSize() const
返回打印机支持的最小物理页面尺寸。
另请参阅 maximumPhysicalPageSize()。
[static]
QPrinterInfo QPrinterInfo::printerInfo(const QString &printerName)
返回打印机printerName 。
使用前应使用isNull() 检查返回值,以防指定的打印机不存在。
另请参阅 isNull()。
QString QPrinterInfo::printerName() const
返回打印机的名称。
这是一个用于标识打印机的唯一 ID,可能不是人可读的。
另请参阅 QPrinterInfo::description() 和QPrinter::setPrinterName()。
QPrinter::PrinterState QPrinterInfo::state() const
返回打印机的当前状态。
根据平台、打印机驱动程序或打印机本身的不同,该状态不一定总是准确的。
QList<QPrinter::ColorMode> QPrinterInfo::supportedColorModes() const
返回打印机支持的颜色模式。
QList<QPrinter::DuplexMode> QPrinterInfo::supportedDuplexModes() const
返回该打印机支持的双面打印模式列表。
QList<QPageSize> QPrinterInfo::supportedPageSizes() const
返回打印机支持的页面尺寸列表。
QList<int> QPrinterInfo::supportedResolutions() const
返回打印机支持的分辨率列表。
bool QPrinterInfo::supportsCustomPageSizes() const
返回打印机是否支持自定义页面尺寸。
QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other)
设置QPrinterInfo 对象等于other 。
© 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.