QWebPluginFactory Class

The QWebPluginFactory class is used to embed custom data types in web pages. 更多...

头: #include <QWebPluginFactory>
Since: Qt 4.4
继承: QObject

公共类型

class MimeType
class Plugin

公共函数

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

额外继承成员

详细描述

The QWebPluginFactory 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 like text/html and image/jpeg , but for any advanced or custom data types you will need to provide a handler yourself.

QWebPluginFactory is a factory for creating plugins for QWebPage , where each plugin provides support for one or more data types. A plugin factory can be installed on a QWebPage 使用 QWebPage::setPluginFactory ().

注意: The plugin factory is only used if plugins are enabled through QWebSettings .

You provide a QWebPluginFactory by implementing the plugins () 和 create () methods. For plugins () 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.

The create () 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 of QObject , but currently only plugins based on either QWidget or QGraphicsWidget are supported.

成员函数文档编制

QWebPluginFactory:: QWebPluginFactory ( QObject * parent = 0)

构造 QWebPluginFactory 采用父级 parent .

[虚拟] QWebPluginFactory:: ~QWebPluginFactory ()

析构函数。

[pure virtual] QObject * QWebPluginFactory:: create (const QString & mimeType , const QUrl & url , const QStringList & argumentNames , const QStringList & argumentValues ) const

Implemented in subclasses to create a new plugin that can display content of the MIME type given by mimeType . The URL of the content is provided in url . The returned object should be a QWidget .

The HTML object element can provide parameters through the <param> tag. The name and the value attributes of these tags are specified by the argumentNames and argumentValues string lists.

例如:

<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:

参数
mimeType "application/x-pdf"
url "http://www.qt.io/document.pdf"
argumentNames "showTableOfContents" "hideThumbnails"
argumentVaues "true" "false"

注意: Ownership of the returned object will be transferred to the caller.

[pure virtual] QList < Plugin > QWebPluginFactory:: plugins () const

This function is reimplemented in subclasses to return a list of supported plugins the factory can create.

注意: Currently, this function is only called when JavaScript programs access the global plugins or mimetypes 对象。

[虚拟] 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.