
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQWebPluginFactory class is used to embed custom data types in web pages.More...
| Header: | #include <QWebPluginFactory> |
| Since: | Qt 4.4 |
| Inherits: | QObject |
| QWebPluginFactory(QObject * parent = 0) | |
| virtual | ~QWebPluginFactory() |
| virtual QObject * | create(const QString & mimeType, const QUrl & url, const QStringList & argumentNames, const QStringList & argumentValues) const = 0 |
| virtual QList<Plugin> | plugins() const = 0 |
| virtual void | refreshPlugins() |
TheQWebPluginFactory class is used to embed custom data types in web pages.
The HTML<object> tag is used to embed arbitrary content into a web page, for example:
<object type="application/x-pdf" data="http://www.qt.io/document.pdf" width="500" height="400"></object>
QtWebkit will natively handle the most basic data types liketext/html andimage/jpeg, but for any advanced or custom data types you will need to provide a handler yourself.
QWebPluginFactory is a factory for creating plugins forQWebPage, where each plugin provides support for one or more data types. A plugin factory can be installed on aQWebPage usingQWebPage::setPluginFactory().
Note:The plugin factory is only used if plugins are enabled throughQWebSettings.
You provide aQWebPluginFactory by implementing theplugins() and thecreate() methods. Forplugins() it is necessary to describe the plugins the factory can create, including a description and the supported MIME types. The MIME types each plugin can handle should match the ones specified in in the HTML<object> tag of your content.
Thecreate() method is called if the requested MIME type is supported. The implementation has to return a new instance of the plugin requested for the given MIME type and the specified URL.
The plugins themselves are subclasses ofQObject, but currently only plugins based on eitherQWidget orQGraphicsWidget are supported.
Constructs aQWebPluginFactory with parentparent.
[virtual]QWebPluginFactory::~QWebPluginFactory()Destructor.
[pure virtual]QObject * QWebPluginFactory::create(constQString & mimeType, constQUrl & url, constQStringList & argumentNames, constQStringList & argumentValues) constImplemented in subclasses to create a new plugin that can display content of the MIME type given bymimeType. The URL of the content is provided inurl. The returned object should be aQWidget.
The HTML object element can provide parameters through the<param> tag. The name and the value attributes of these tags are specified by theargumentNames andargumentValues string lists.
For example:
<object type="application/x-pdf" data="http://www.qt.io/document.pdf" width="500" height="400"><param name="showTableOfContents" value="true"/><param name="hideThumbnails" value="false"/></object>
The above object element will result in a call to create() with the following arguments:
| Parameter | Value |
|---|---|
| mimeType | "application/x-pdf" |
| url | "http://www.qt.io/document.pdf" |
| argumentNames | "showTableOfContents" "hideThumbnails" |
| argumentVaues | "true" "false" |
Note:Ownership of the returned object will be transferred to the caller.
[pure virtual]QList<Plugin> QWebPluginFactory::plugins() constThis function is reimplemented in subclasses to return a list of supported plugins the factory can create.
Note:Currently, this function is only called when JavaScript programs access the globalplugins ormimetypes objects.
[virtual]void QWebPluginFactory::refreshPlugins()This function is called to refresh the list of supported plugins. It may be called after a new plugin has been installed in the system.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.