QPdfSearchModel 類

QPdfSearchModel 類搜索 PDF 文檔中的字符串並保持結果。 更多...

頭: #include <QPdfSearchModel>
繼承: QAbstractListModel

公共類型

枚舉類 角色 { Page, IndexOnPage, Location, ContextBefore, ContextAfter }

特性

公共函數

QPdfSearchModel (QObject * parent )
virtual ~QPdfSearchModel () override
int count () const
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 countChanged ()
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:

成員類型文檔編製

enum class QPdfSearchModel:: 角色

常量 描述
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 .

特性文檔編製

[read-only, since 6.8] count : const int

This property holds the number of search results found

該特性在 Qt 6.8 引入。

訪問函數:

int count () const

通知程序信號:

void countChanged ()

document : QPdfDocument *

此特性保持要搜索文檔

訪問函數:

QPdfDocument * document () const
void setDocument (QPdfDocument * document )

通知程序信號:

void documentChanged ()

searchString : QString

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.

QPdfLink QPdfSearchModel:: resultAtIndex ( int index ) const

Returns a result found by index document , regardless of the page on which it was found. index must be less than rowCount .

QList < QPdfLink > QPdfSearchModel:: resultsOnPage ( int page ) const

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.