PySide6.QtPrintSupport.QPrinterInfo

class QPrinterInfo

QPrinterInfo 类提供了访问现有打印机信息的途径。更多

概要

方法

静态函数

注意

本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。

详细描述

使用静态函数生成一个QPrinterInfo对象列表。列表中的每个QPrinterInfo对象代表一个打印机,并且可以查询名称、支持的纸张大小以及是否是默认打印机。

__init__()

构造一个空的 QPrinterInfo 对象。

另请参阅

isNull()

__init__(printer)
Parameters:

打印机QPrinter

printer构造一个QPrinterInfo对象。

__init__(other)
Parameters:

其他QPrinterInfo

构造other的副本。

static availablePrinterNames()
Return type:

字符串列表

返回此系统上所有可用打印机名称的列表。

建议使用此方法代替availablePrinters(),因为在大多数系统上它会更快。

请注意,如果在本地系统或远程打印服务器上进行了更改,列表可能会过时。仅在需要时实例化所需的QPrinterInfo实例,并在调用前始终检查其有效性。

static availablePrinters()
Return type:

QPrinterInfo的列表

返回系统中所有可用打印机的QPrinterInfo对象列表。

不建议使用这种方法,因为创建每个打印机实例可能需要很长时间,特别是在有远程网络打印机的情况下,如果本地系统或远程打印服务器发生更改,保留的实例可能会过时。请改用availablePrinterNames(),并仅在需要时实例化打印机实例。

defaultColorMode()
Return type:

ColorMode

返回此打印机的默认颜色模式。

defaultDuplexMode()
Return type:

DuplexMode

返回此打印机的默认双面模式。

defaultPageSize()
Return type:

QPageSize

返回此打印机的当前默认页面大小。

static defaultPrinter()
Return type:

QPrinterInfo

返回系统上的默认打印机。

在使用返回值之前,应使用isNull()进行检查,以防没有默认打印机。

在某些系统上,可能会出现有可用打印机但没有设置默认打印机的情况。

static defaultPrinterName()
Return type:

字符串

返回当前默认打印机的名称。

description()
Return type:

字符串

返回打印机的可读描述。

另请参阅

printerName()

isDefault()
Return type:

布尔

返回此打印机当前是否为默认打印机。

isNull()
Return type:

布尔

返回此QPrinterInfo对象是否包含打印机定义。

一个空的 QPrinterInfo 对象可能是由于在系统上没有打印机时调用 defaultPrinter() 而产生的。

isRemote()
Return type:

布尔

返回此打印机是否为远程网络打印机。

location()
Return type:

字符串

返回打印机的可读位置。

makeAndModel()
Return type:

字符串

返回打印机的可读制造商和型号。

maximumPhysicalPageSize()
Return type:

QPageSize

返回此打印机支持的最大物理页面大小。

minimumPhysicalPageSize()
Return type:

QPageSize

返回此打印机支持的最小物理页面大小。

static printerInfo(printerName)
Parameters:

printerName – str

Return type:

QPrinterInfo

返回打印机 printerName

返回值应在使用前使用isNull()进行检查,以防指定的打印机不存在。

另请参阅

isNull()

printerName()
Return type:

字符串

返回打印机的名称。

这是一个用于识别打印机的唯一ID,可能不易于人类阅读。

state()
Return type:

PrinterState

返回此打印机的当前状态。

此状态可能并不总是准确的,取决于平台、打印机驱动程序或打印机本身。

supportedColorModes()
Return type:

QPrinter.ColorMode 的列表

返回此打印机支持的颜色模式。

supportedDuplexModes()
Return type:

QPrinter.DuplexMode 的列表

返回此打印机支持的双面模式列表。

supportedPageSizes()
Return type:

QPageSize的列表

返回此打印机支持的页面尺寸列表。

supportedResolutions()
Return type:

整数列表

返回此打印机支持的分辨率列表。

supportsCustomPageSizes()
Return type:

布尔

返回此打印机是否支持自定义页面大小。