QPdfSearchModel 类搜索 PDF 文档中的字符串并保持结果。 更多...
头: | #include <QPdfSearchModel> |
继承: | QAbstractListModel |
enum class | Role { Page, IndexOnPage, Location, ContextBefore, ContextAfter } |
QPdfSearchModel (QObject * parent ) | |
virtual | ~QPdfSearchModel () override |
QPdfDocument * | document () const |
QPdfLink | resultAtIndex (int index ) const |
QList<QPdfLink> | resultsOnPage (int page ) const |
QString | searchString () const |
virtual QVariant | data (const QModelIndex & index , int role ) const override |
virtual QHash<int, QByteArray> | roleNames () const override |
virtual int | rowCount (const QModelIndex & parent ) const override |
void | setDocument (QPdfDocument * document ) |
void | setSearchString (const QString & searchString ) |
void | documentChanged () |
void | searchStringChanged () |
This is used in the 模型/视图编程 paradigm to display a list of search results, to highlight them on the rendered PDF pages, and to iterate through them using the "search forward" / "search backward" buttons and shortcuts that would be found in a typical document-viewing UI:
常量 | 值 | 描述 |
---|---|---|
QPdfSearchModel::Role::Page
|
Qt::UserRole
|
The page number where the search result is found (int). |
QPdfSearchModel::Role::IndexOnPage
|
257
|
The index of the search result on the page (int). |
QPdfSearchModel::Role::Location
|
258
|
The position of the search result on the page ( QPointF ). |
QPdfSearchModel::Role::ContextBefore
|
259
|
The adjacent text on the page, before the search string ( QString ). |
QPdfSearchModel::Role::ContextAfter
|
260
|
The adjacent text on the page, after the search string ( QString ). |
另请参阅 QPdfLink .
此特性保持要搜索文档
访问函数:
QPdfDocument * | document () const |
void | setDocument (QPdfDocument * document ) |
通知程序信号:
void | documentChanged () |
This property holds the string to search for
访问函数:
QString | searchString () const |
void | setSearchString (const QString & searchString ) |
通知程序信号:
void | searchStringChanged () |
[explicit]
QPdfSearchModel::
QPdfSearchModel
(
QObject
*
parent
)
Constructs a new search model with parent object parent .
[override virtual noexcept]
QPdfSearchModel::
~QPdfSearchModel
()
Destroys the model.
[override virtual]
QVariant
QPdfSearchModel::
data
(const
QModelIndex
&
index
,
int
role
) const
重实现: QAbstractItemModel::data(const QModelIndex &index, int role) const .
Returns a result found by index 在 document , regardless of the page on which it was found. index must be less than rowCount .
Returns the list of all results found on the given page .
[override virtual]
QHash
<
int
,
QByteArray
> QPdfSearchModel::
roleNames
() const
重实现: QAbstractItemModel::roleNames() const .
[override virtual]
int
QPdfSearchModel::
rowCount
(const
QModelIndex
&
parent
) const
重实现: QAbstractItemModel::rowCount(const QModelIndex &parent) const .
The number of rows in the model is equal to the number of search results found.