|  | Home · All Classes · Modules

# QHelpSearchEngine Class Reference
[QtHelp module]

The QHelpSearchEngine class provides access to widgets reusable to integrate fulltext search as well as to index and search documentation. More...

Inherits QObject.

### Methods

- __init__ (self, QHelpEngineCore helpEngine, QObject parent = None)
- cancelIndexing (self)
- cancelSearching (self)
- int hitCount (self)
- list-of-tuple-of-QString-QString hits (self, int start, int end)
- int hitsCount (self)
- list-of-QHelpSearchQuery query (self)
- QHelpSearchQueryWidget queryWidget (self)
- reindexDocumentation (self)
- QHelpSearchResultWidget resultWidget (self)
- search (self, list-of-QHelpSearchQuery queryList)

### Qt Signals

- void indexingFinished ()
- void indexingStarted ()
- void searchingFinished (int)
- void searchingStarted ()

## Detailed Description

The QHelpSearchEngine class provides access to widgets reusable to integrate fulltext search as well as to index and search documentation.

Before the search engine can be used, one has to instantiate at least a QHelpEngineCore object that needs to be passed to the search engines constructor. This is required as the search engine needs to be connected to the help engines setupFinished() signal to know when it can start to index documentation.

After starting the indexing process the signal indexingStarted() is emitted and on the end of the indexing process the indexingFinished() is emitted. To stop the indexing one can call cancelIndexing().

While the indexing process has finished, the search engine can now be used to search thru its index for a given term. To do this one may use the possibility of creating the QHelpSearchQuery list by self or reuse the QHelpSearchQueryWidget which has the inbuild functionality to set up a proper search queries list that get's passed to the search engines search() function.

After the list of querys has been passed to the search engine, the signal searchingStarted() is emitted and after the search has finished the searchingFinished() signal is emitted. The search process can be stopped by calling cancelSearching().

If the search succeeds, the searchingFinished() will be called with the search hits count, which can be reused to fetch the search hits from the search engine. Calling the hits() function with the range of hits you would like to get will return a list of the requested SearchHits. They basically constist at the moment of a pair of strings where the values of that pair are the documentation file path and the page title.

To display the given hits use the QHelpSearchResultWidget or build up your own one if you need more advanced functionality. Note that the QHelpSearchResultWidget can not be instantiated directly, you must retrieve the widget from the search engine in use as all connections will be established for you by the widget itself.

## Method Documentation

### QHelpSearchEngine.__init__ (self, QHelpEngineCore helpEngine, QObject parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a new search engine with the given parent. The search engine uses the given helpEngine to access the documentation that needs to be indexed. The QHelpEngine's setupFinished() signal is automatically connected to the QHelpSearchEngine's indexing function, so that new documentation will be indexed after the signal is emitted.

### QHelpSearchEngine.cancelIndexing (self)

This method is also a Qt slot with the C++ signature `void cancelIndexing()`.

Stops the indexing process.

### QHelpSearchEngine.cancelSearching (self)

This method is also a Qt slot with the C++ signature `void cancelSearching()`.

Stops the search process.

### int QHelpSearchEngine.hitCount (self)

Returns the amount of hits the search engine found.

This function was introduced in Qt 4.6.

### list-of-tuple-of-QString-QString QHelpSearchEngine.hits (self, int start, int end)

Returns a list of search hits within the range of start end.

### int QHelpSearchEngine.hitsCount (self)

### list-of-QHelpSearchQuery QHelpSearchEngine.query (self)

Returns the list of queries last searched for.

This function was introduced in Qt 4.5.

### QHelpSearchQueryWidget QHelpSearchEngine.queryWidget (self)

Returns a widget to use as input widget. Depending on your search engine configuration you will get a different widget with more or less subwidgets.

### QHelpSearchEngine.reindexDocumentation (self)

This method is also a Qt slot with the C++ signature `void reindexDocumentation()`.

Forces the search engine to reindex all documentation files.

### QHelpSearchResultWidget QHelpSearchEngine.resultWidget (self)

Returns a widget that can hold and display the search results.

### QHelpSearchEngine.search (self, list-of-QHelpSearchQuery queryList)

This method is also a Qt slot with the C++ signature `void search(const QList<QHelpSearchQuery>&)`.

Starts the search process using the given list of queries queryList build by the search field name and the values to search for.

## Qt Signal Documentation

### void indexingFinished ()

This is the default overload of this signal.

This signal is emitted when the indexing process is complete.

### void indexingStarted ()

This is the default overload of this signal.

This signal is emitted when indexing process is started.

### void searchingFinished (int)

This is the default overload of this signal.

This signal is emitted when the search process is complete. The hit count is stored in hits.

### void searchingStarted ()

This is the default overload of this signal.

This signal is emitted when the search process is started.