QWebEngineExtensionManager Class

The QWebEngineExtensionManager class allows applications to install and load Chrome extensions from the filesystem. 更多...

頭: #include <QWebEngineExtensionManager>
CMake: find_package(Qt6 REQUIRED COMPONENTS WebEngineCore)
target_link_libraries(mytarget PRIVATE Qt6::WebEngineCore)
qmake: QT += webenginecore
Since: Qt 6.10
繼承: QObject

特性

公共函數

QList<QWebEngineExtensionInfo> extensions () const
void installExtension (const QString & path )
QString installPath () const
void loadExtension (const QString & path )
void setExtensionEnabled (const QWebEngineExtensionInfo & extension , bool enabled )
void uninstallExtension (const QWebEngineExtensionInfo & extension )
void unloadExtension (const QWebEngineExtensionInfo & extension )

重實現保護函數

virtual bool event (QEvent * e ) override

詳細描述

QWebEngineExtensionManager can load or install Chrome extensions. Extensions can be loaded via loadExtension . Extensions loaded this way are not remembered by the associated profile and has to be manually loaded in every new browsing session. To preserve extensions between browsing sessions, applications can install zipped or unpacked extensions via installExtension . In this case the manager will unpack the extension to the profile's directory and load it from there. Installed extensions are always loaded at startup, after the profile is initialized.

You can access the loaded extensions with extensions () which provides a list of QWebEngineExtensionInfo , or connect to the manager's signals to get notified about the state of the load or install processes.

每個 QWebEngineProfile has its own QWebEngineExtensionManager , so every page that shares the same profile will share the same extensions too. Extensions can't be loaded into off-the-record profiles.

注意: Only ManifestV3 extensions are supported, other versions won't be loaded nor installed

另請參閱 QWebEngineProfile::extensionManager and QWebEngineExtensionInfo .

特性文檔編製

[read-only] extensions : const QList < QWebEngineExtensionInfo >

Returns a list of the loaded extensions.

訪問函數:

QList<QWebEngineExtensionInfo> extensions () const

另請參閱 QWebEngineExtensionInfo .

[read-only] installPath : const QString

Returns the directory's path where the extensions are installed.

訪問函數:

QString installPath () const

另請參閱 installExtension () 和 QWebEngineExtensionInfo::isInstalled ().

成員函數文檔編製

[override virtual protected] bool QWebEngineExtensionManager:: event ( QEvent * e )

重實現: QObject::event (QEvent *e).

[invokable] void QWebEngineExtensionManager:: installExtension (const QString & path )

Installs an extension from path to the profile's directory and loads it

The QWebEngineExtensionManager::installFinished signal is emitted after an extension is installed or the install failed. If the install succeeded QWebEngineExtensionInfo::isInstalled () will return true, otherwise QWebEngineExtensionInfo::error () will contain information how the install process failed.

Extensions are loaded in disabled state after the install succeded. Installed extensions are automatically loaded at every starutup in disabled state. The install path can be queried with installPath ().

The installer is capable of installing zipped or unpacked extensions. The path parameter should point to a directory or a zip file containing the extension's manifest file. If the manifest is missing from the top level directory, the install process will abort.

Installing an already loaded or installed extension from the same path will install a new extension.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

另請參閱 QWebEngineExtensionInfo::isInstalled (), QWebEngineExtensionInfo::error (),和 installPath ().

[invokable] void QWebEngineExtensionManager:: loadExtension (const QString & path )

Loads an unpacked extension from path

The QWebEngineExtensionManager::loadFinished signal is emitted when an extension is loaded or the load failed. If the load succeeded QWebEngineExtensionInfo::isLoaded () will return true otherwise QWebEngineExtensionInfo::error () will contain information where the loading process failed.

Extensions are always loaded in disabled state, users have to enable them manually. Loading an already loaded extension from the same path will reload the extension.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

另請參閱 QWebEngineExtensionInfo::isLoaded () 和 QWebEngineExtensionInfo::error ().

[invokable] void QWebEngineExtensionManager:: setExtensionEnabled (const QWebEngineExtensionInfo & extension , bool enabled )

Allows to turn on/off the extension at runtime

The enabled argument determines whether the extension should be enabled or disabled.

注意: It is also possible to disable internal extensions like Hangouts and PDF.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

另請參閱 QWebEngineExtensionInfo::isEnabled ().

[invokable] void QWebEngineExtensionManager:: uninstallExtension (const QWebEngineExtensionInfo & extension )

Uninstalls the extension

Removes the extension's files from the install path and unloads the extension. The QWebEngineExtensionManager::uninstallFinished signal is emitted after the process finished.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

另請參閱 QWebEngineExtensionManager::installPath (), QWebEngineExtensionInfo::isInstalled (),和 QWebEngineExtensionInfo::error ().

[invokable] void QWebEngineExtensionManager:: unloadExtension (const QWebEngineExtensionInfo & extension )

Unloads the extension

Removes all the extension's data from memory.

The QWebEngineExtensionManager::unloadFinished signal is emitted after the unload process finished.

注意: It is also possible to unload internal extensions like Hangouts and PDF, but they will be loaded at next startup like other installed extensions.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

另請參閱 QWebEngineExtensionInfo::isLoaded ().