PySide6.QtPdf.QPdfSearchModel

class QPdfSearchModel

QPdfSearchModel 类在 PDF 文档中搜索字符串并保存结果。更多

PySide6.QtPdf.QPdfSearchModel 的继承图

概要

属性

方法

插槽

信号

注意

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

详细描述

这用于模型/视图编程范式,以显示搜索结果列表,在渲染的PDF页面上突出显示它们,并使用典型的文档查看用户界面中会找到的“向前搜索”/“向后搜索”按钮和快捷方式来遍历它们:

../../_images/search-results.png
class Role

常量

描述

QPdfSearchModel.Role.Page

找到搜索结果的页码(整数)。

QPdfSearchModel.Role.IndexOnPage

搜索结果在页面上的索引(整数)。

QPdfSearchModel.Role.Location

搜索结果在页面上的位置(QPointF)。

QPdfSearchModel.Role.ContextBefore

页面上的相邻文本,位于搜索字符串之前(QString)。

QPdfSearchModel.Role.ContextAfter

页面上的相邻文本,位于搜索字符串之后(QString)。

另请参阅

QPdfLink

注意

当使用from __feature__ import true_property时,属性可以直接使用,否则通过访问器函数使用。

property countᅟ: int

此属性保存找到的搜索结果数量。

Access functions:
property documentᅟ: QPdfDocument

此属性保存要搜索的文档。

Access functions:
property searchStringᅟ: str

此属性保存要搜索的字符串。

Access functions:
__init__()
__init__(parent)
Parameters:

父对象QObject

使用父对象 parent 构造一个新的搜索模型。

count()
Return type:

整数

属性 countᅟ 的获取器。

countChanged()

属性 countᅟ 的通知信号。

document()
Return type:

QPdfDocument

另请参阅

setDocument()

属性 documentᅟ 的获取器。

documentChanged()

属性 documentᅟ 的通知信号。

resultAtIndex(index)
Parameters:

索引 – int

Return type:

QPdfLink

返回在document中通过index找到的结果,无论它是在哪个页面上找到的。index必须小于rowCount

resultsOnPage(page)
Parameters:

页码 – int

Return type:

QPdfLink的列表

返回在给定page上找到的所有结果的列表。

searchString()
Return type:

字符串

另请参阅

setSearchString()

属性 searchStringᅟ 的获取器。

searchStringChanged()

属性 searchStringᅟ 的通知信号。

setDocument(document)
Parameters:

文档QPdfDocument

另请参阅

document()

属性 documentᅟ 的设置器。

setSearchString(searchString)
Parameters:

searchString – 字符串

另请参阅

searchString()

属性 searchStringᅟ 的设置器。

updatePage(page)
Parameters:

页码 – int