QHelpEngineCore 类提供帮助系统的核心功能。 更多...
头: | #include <QHelpEngineCore> |
CMake: |
find_package(Qt6 COMPONENTS Help REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Help) |
qmake: | QT += help |
继承: | QObject |
继承者: | QHelpEngine |
QHelpEngineCore (const QString & collectionFile , QObject * parent = nullptr) | |
virtual | ~QHelpEngineCore () |
bool | autoSaveFilter () const |
QString | collectionFile () const |
bool | copyCollectionFile (const QString & fileName ) |
QVariant | customValue (const QString & key , const QVariant & defaultValue = QVariant()) const |
QString | documentationFileName (const QString & namespaceName ) |
QList<QHelpLink> | documentsForIdentifier (const QString & id ) const |
QList<QHelpLink> | documentsForIdentifier (const QString & id , const QString & filterName ) const |
QList<QHelpLink> | documentsForKeyword (const QString & keyword ) const |
QList<QHelpLink> | documentsForKeyword (const QString & keyword , const QString & filterName ) const |
QString | error () const |
QByteArray | fileData (const QUrl & url ) const |
QList<QUrl> | 文件 (const QString namespaceName , const QString & filterName , const QString & extensionFilter = QString()) |
QHelpFilterEngine * | filterEngine () const |
QUrl | findFile (const QUrl & url ) const |
bool | isReadOnly () const |
bool | registerDocumentation (const QString & documentationFileName ) |
QStringList | registeredDocumentations () const |
bool | removeCustomValue (const QString & key ) |
void | setAutoSaveFilter (bool save ) |
void | setCollectionFile (const QString & fileName ) |
bool | setCustomValue (const QString & key , const QVariant & value ) |
void | setReadOnly (bool enable ) |
void | setUsesFilterEngine (bool 使用 ) |
bool | setupData () |
bool | unregisterDocumentation (const QString & namespaceName ) |
bool | usesFilterEngine () const |
void | setupFinished () |
void | setupStarted () |
void | warning (const QString & msg ) |
QVariant | metaData (const QString & documentationFileName , const QString & name ) |
QString | namespaceName (const QString & documentationFileName ) |
在可以使用帮助引擎前,必须初始化它通过调用 setupData (). At the beginning of the setup process the signal setupStarted () is emitted. From this point on until the signal setupFinished () is emitted, is the help data in an undefined meaning unusable state.
The core help engine can be used to perform different tasks. By calling documentsForIdentifier () the engine returns URLs specifying the file locations inside the help system. The actual file data can then be retrived by calling fileData ().
The help engine can contain any number of custom filters. The management of the filters, including adding new filters, changing filter definitions, or removing existing filters, is done through the QHelpFilterEngine class, which can be accessed by the filterEngine () 方法。
注意:
QHelpFilterEngine
replaces the older filter API that is deprecated since Qt 5.13. Call
setUsesFilterEngine
() 采用
true
to enable the new functionality.
The core help engine has two modes:
The mode can be changed by calling setReadOnly () method, prior to calling setupData ().
The help engine also offers the possibility to set and read values in a persistent way comparable to ini files or Windows registry entries. For more information see setValue() or value().
This class does not offer any GUI components or functionality for indices or contents. If you need one of those use QHelpEngine 代替。
此特性保持是否 QHelpEngineCore is in auto save filter mode or not.
若 QHelpEngineCore is in auto save filter mode, the current filter is automatically saved when it is changed by the QHelpFilterEngine::setActiveFilter () function. The filter is saved persistently in the help collection file.
By default, this mode is on.
访问函数:
bool | autoSaveFilter () const |
void | setAutoSaveFilter (bool save ) |
This property holds the absolute file name of the collection file currently used.
Setting this property leaves the help engine in an invalid state. It is important to invoke setupData () or any getter function in order to setup the help engine again.
访问函数:
QString | collectionFile () const |
void | setCollectionFile (const QString & fileName ) |
[since 6.0]
readOnly
:
bool
This property holds whether the help engine is read-only.
In read-only mode, the user can use the help engine with a collection file installed in a read-only location. In this case, some functionality won't be accessible, like registering additional documentation, filter editing, or any action that would require changes to the collection file. Setting it to
false
enables the full functionality of the help engine.
默认情况下,此特性为
true
.
This property was introduced in Qt 6.0.
访问函数:
bool | isReadOnly () const |
void | setReadOnly (bool enable ) |
Constructs a new core help engine with a parent 。帮助引擎所用信息存储于 collectionFile to provide help. If the collection file does not exist yet, it'll be created.
[signal]
void
QHelpEngineCore::
setupFinished
()
This signal is emitted when the setup is complete.
[signal]
void
QHelpEngineCore::
setupStarted
()
This signal is emitted when setup is started.
[signal]
void
QHelpEngineCore::
warning
(const
QString
&
msg
)
This signal is emitted when a non critical error occurs. The warning message is stored in msg .
[虚拟]
QHelpEngineCore::
~QHelpEngineCore
()
Destructs the help engine.
Creates the file fileName and copies all contents from the current collection file into the newly created file, and returns true if successful; otherwise returns false.
The copying process makes sure that file references to Qt Collection files (
.qch
) files are updated accordingly.
Returns the value assigned to the key . If the requested key does not exist, the specified defaultValue 被返回。
另请参阅 setCustomValue () 和 removeCustomValue ().
Returns the absolute file name of the Qt compressed help file (.qch) identified by the namespaceName . If there is no Qt compressed help file with the specified namespace registered, an empty string is returned.
另请参阅 namespaceName ().
[since 5.15]
QList
<
QHelpLink
> QHelpEngineCore::
documentsForIdentifier
(const
QString
&
id
) const
Returns a list of all the document links found for the id . The returned list contents depend on the current filter, and therefore only the keywords registered for the current filter will be returned.
该函数在 Qt 5.15 引入。
[since 5.15]
QList
<
QHelpLink
> QHelpEngineCore::
documentsForIdentifier
(const
QString
&
id
, const
QString
&
filterName
) const
Returns a list of the document links found for the id , filtered by filterName . The returned list contents depend on the passed filter, and therefore only the keywords registered for this filter will be returned. If you want to get all results unfiltered, pass empty string as filterName .
该函数在 Qt 5.15 引入。
[since 5.15]
QList
<
QHelpLink
> QHelpEngineCore::
documentsForKeyword
(const
QString
&
keyword
) const
Returns a list of all the document links found for the keyword . The returned list contents depend on the current filter, and therefore only the keywords registered for the current filter will be returned.
该函数在 Qt 5.15 引入。
[since 5.15]
QList
<
QHelpLink
> QHelpEngineCore::
documentsForKeyword
(const
QString
&
keyword
, const
QString
&
filterName
) const
Returns a list of the document links found for the keyword , filtered by filterName . The returned list contents depend on the passed filter, and therefore only the keywords registered for this filter will be returned. If you want to get all results unfiltered, pass empty string as filterName .
该函数在 Qt 5.15 引入。
Returns a description of the last error that occurred.
Returns the data of the file specified by url . If the file does not exist, an empty QByteArray 被返回。
另请参阅 findFile ().
Returns a list of files contained in the Qt compressed help file for namespaceName . The files can be filtered by filterName as well as by their extension extensionFilter (for example, 'html').
[since 5.13]
QHelpFilterEngine
*QHelpEngineCore::
filterEngine
() const
Returns the filter engine associated with this help engine. The filter engine allows for adding, changing, and removing existing filters for this help engine. To use the engine you also have to call
setUsesFilterEngine
() 设为
true
.
该函数在 Qt 5.13 引入。
Returns the corrected URL for the url that may refer to a different namespace defined by the virtual folder defined as a part of the url . If the virtual folder matches the namespace of the url , the method just checks if the file exists and returns the same url . When the virtual folder doesn't match the namespace of the url , it tries to find the best matching namespace according to the active filter. When the namespace is found, it returns the corrected URL if the file exists, otherwise it returns an invalid URL.
[static]
QVariant
QHelpEngineCore::
metaData
(const
QString
&
documentationFileName
, const
QString
&
name
)
Returns the meta data for the Qt compressed help file documentationFileName . If there is no data available for name , an invalid QVariant() is returned. The meta data is defined when creating the Qt compressed help file and cannot be modified later. Common meta data includes e.g. the author of the documentation.
[static]
QString
QHelpEngineCore::
namespaceName
(const
QString
&
documentationFileName
)
Returns the namespace name defined for the Qt compressed help file (.qch) specified by its documentationFileName . If the file is not valid, an empty string is returned.
另请参阅 documentationFileName ().
Registers the Qt compressed help file (.qch) contained in the file documentationFileName . One compressed help file, uniquely identified by its namespace can only be registered once. True is returned if the registration was successful, otherwise false.
另请参阅 unregisterDocumentation () 和 error ().
Returns a list of all registered Qt compressed help files of the current collection file. The returned names are the namespaces of the registered Qt compressed help files (.qch).
移除 key from the settings section in the collection file. Returns true if the value was removed successfully, otherwise false.
另请参阅 customValue () 和 setCustomValue ().
Save the value under the key . If the key already exist, the value will be overwritten. Returns true if the value was saved successfully, otherwise false.
另请参阅 customValue () 和 removeCustomValue ().
[since 5.13]
void
QHelpEngineCore::
setUsesFilterEngine
(
bool
使用
)
Enables or disables the new filter engine functionality inside the help engine, according to the passed 使用 参数。
该函数在 Qt 5.13 引入。
另请参阅 usesFilterEngine () 和 filterEngine ().
Sets up the help engine by processing the information found in the collection file and returns true if successful; otherwise returns false.
By calling the function, the help engine is forced to initialize itself immediately. Most of the times, this function does not have to be called explicitly because getter functions which depend on a correctly set up help engine do that themselves.
注意:
qsqlite4.dll
needs to be deployed with the application as the help system uses the sqlite driver when loading help collections.
Unregisters the Qt compressed help file (.qch) identified by its namespaceName from the help collection. Returns true on success, otherwise false.
另请参阅 registerDocumentation () 和 error ().
[since 5.13]
bool
QHelpEngineCore::
usesFilterEngine
() const
Returns whether the help engine uses the new filter functionality.
该函数在 Qt 5.13 引入。
另请参阅 setUsesFilterEngine () 和 filterEngine ().