- Qt 6.8
- Qt Help
- C++ Classes
- QHelpSearchEngineCore
- Qt 6.8.0 Reference Documentation

# QHelpSearchEngineCore Class

The QHelpSearchEngineCore class provides access to index and search documentation. More...

Header: | `#include <QHelpSearchEngineCore>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Help)` `target_link_libraries(mytarget PRIVATE Qt6::Help)`
qmake: | `QT += help`
Since: | Qt 6.8

- List of all members, including inherited members

## Public Functions

| QHelpSearchEngineCore(QHelpEngineCore *helpEngine, QObject *parent = nullptr)
virtual | ~QHelpSearchEngineCore() override
QString | searchInput() const
int | searchResultCount() const
QList<QHelpSearchResult> | searchResults(int start, int end) const

## Public Slots

void | cancelIndexing()
void | cancelSearching()
void | reindexDocumentation()
void | search(const QString &searchInput)

## Signals

void | indexingFinished()
void | indexingStarted()
void | searchingFinished()
void | searchingStarted()

## Detailed Description

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().

When the indexing process has finished, the search engine can be used to search through the index for a given term using the search() function. When the search input is passed to the search engine, the searchingStarted() signal is emitted. When the search finishes, the searchingFinished() signal is emitted. The search process can be stopped by calling cancelSearching().

If the search succeeds, searchingFinished() is called with the search result count to fetch the search results from the search engine. Calling the searchResults() function with a range returns a list of QHelpSearchResult objects within the range. The results consist of the document title and URL, as well as a snippet from the document that contains the best match for the search input.

## Member Function Documentation

### `[explicit]` QHelpSearchEngineCore::QHelpSearchEngineCore(QHelpEngineCore *helpEngine, QObject *parent = nullptr)

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 QHelpEngineCore's setupFinished() signal is automatically connected to the QHelpSearchEngineCore's indexing function, so that new documentation will be indexed after the signal is emitted.

### `[override virtual noexcept]` QHelpSearchEngineCore::~QHelpSearchEngineCore()

Destructs the search engine.

### `[slot]` void QHelpSearchEngineCore::cancelIndexing()

Stops the indexing process.

### `[slot]` void QHelpSearchEngineCore::cancelSearching()

Stops the search process.

### `[signal]` void QHelpSearchEngineCore::indexingFinished()

This signal is emitted when the indexing process is complete.

### `[signal]` void QHelpSearchEngineCore::indexingStarted()

This signal is emitted when indexing process is started.

### `[slot]` void QHelpSearchEngineCore::reindexDocumentation()

Forces the search engine to reindex all documentation files.

### `[slot]` void QHelpSearchEngineCore::search(const QString &searchInput)

Starts the search process using the given search phrase searchInput.

The phrase may consist of several words. By default, the search engine returns the list of documents that contain all the specified words. The phrase may contain any combination of the logical operators AND, OR, and NOT. The operator must be written in all capital letters, otherwise it will be considered a part of the search phrase.

If double quotation marks are used to group the words, the search engine will search for an exact match of the quoted phrase.

For more information about the text query syntax, see SQLite FTS5 Extension.

### QString QHelpSearchEngineCore::searchInput() const

Returns the phrase that was last searched for.

### int QHelpSearchEngineCore::searchResultCount() const

Returns the number of results the search engine found.

### QList<QHelpSearchResult> QHelpSearchEngineCore::searchResults(int start, int end) const

Returns a list of search results within the range from the index specified by start to the index specified by end.

### `[signal]` void QHelpSearchEngineCore::searchingFinished()

This signal is emitted when the search process is complete.

### `[signal]` void QHelpSearchEngineCore::searchingStarted()

This signal is emitted when the search process is started.