如何为QtWebKit开发插件?

时间:2023-01-15 15:36:19

I am trying to develop a plug-in for QtWebkit. But I am not able to find how to develop a plugin for QtWebKit, hopefully one that can be invoked by JavaScript. Does anyone know of any tutorials or documents that explain how to do this?

我正在尝试为QtWebkit开发一个插件。但我无法找到如何为QtWebKit开发插件,希望可以通过JavaScript调用它。有没有人知道任何解释如何执行此操作的教程或文档?

Webkit has been intregated into Qt and this integrated package is called QtWebkit. They have provided new method for for plugin creation.

Webkit已被嵌入到Qt中,这个集成包被称为QtWebkit。他们为插件创建提供了新方法。

-Regards, Vivek Gupta

-Regards,Vivek Gupta

4 个解决方案

#1


4  

The simple answer is to write a subclass of QWebPage and set this on your webview. Then you can show your own HTML page and react to the appropriate object tag in the createPlugin method;

简单的答案是编写QWebPage的子类并在webview上设置它。然后,您可以显示自己的HTML页面,并对createPlugin方法中的相应对象标记做出反应;

protected:
   QObject* createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
   {
      if (classid=="lineedit") {
         QLineEdit *lineedit = new QLineEdit;
         return lineedit;
      }
      return 0;
}

and show something like the following HTML;

并显示类似以下HTML的内容;

<object type="application/x-qt-plugin" classid="lineedit" id="lineedit">
can't load plugin
</object>

Remeber you need to turn on plugins, and possibly also JavaScript if you want more advanced functionality in the QWebSettings

记住你需要打开插件,如果你想在QWebSettings中想要更高级的功能,也可能打开JavaScript

To have more advanced functionality, you should use a QWebPluginFactory

要获得更高级的功能,您应该使用QWebPluginFactory

#2


1  

Actually Webkit has been intregated in Qt and this intregated package is called QtWebkit. And they have provided new method for for plugin creation.I just need a link or steps for creating a plugin in QtWebkit and that plugin should be invoked by java script.

实际上Webkit已经在Qt中被集成,这个被嵌入的包被称为QtWebkit。并且它们为插件创建提供了新方法。我只需要一个或多个链接来在QtWebkit中创建插件,该插件应该由java脚本调用。

Regards Vivek Gupta

关心Vivek Gupta

#3


0  

Introduction to WebKit Plug-in Programming Topics is for WebKit, is QtWebKit that special?

WebKit简介插件编程主题是针对WebKit的,QtWebKit是特别的吗?

#4


0  

To expose the object to Javascript, use

要将对象公开给Javascript,请使用

this->mainFrame()->addToJavaScriptWindowObject("lineedit", this);

where lineedit is the name that can be used to access the object from javascript

其中lineedit是可用于从javascript访问对象的名称

Qt properties will be exposed as JavaScript properties and slots as JavaScript methods. (see http://doc.qt.io/archives/qt-4.7/qwebframe.html#addToJavaScriptWindowObject)

Qt属性将作为JavaScript属性和插槽显示为JavaScript方法。 (参见http://doc.qt.io/archives/qt-4.7/qwebframe.html#addToJavaScriptWindowObject)

#1


4  

The simple answer is to write a subclass of QWebPage and set this on your webview. Then you can show your own HTML page and react to the appropriate object tag in the createPlugin method;

简单的答案是编写QWebPage的子类并在webview上设置它。然后,您可以显示自己的HTML页面,并对createPlugin方法中的相应对象标记做出反应;

protected:
   QObject* createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
   {
      if (classid=="lineedit") {
         QLineEdit *lineedit = new QLineEdit;
         return lineedit;
      }
      return 0;
}

and show something like the following HTML;

并显示类似以下HTML的内容;

<object type="application/x-qt-plugin" classid="lineedit" id="lineedit">
can't load plugin
</object>

Remeber you need to turn on plugins, and possibly also JavaScript if you want more advanced functionality in the QWebSettings

记住你需要打开插件,如果你想在QWebSettings中想要更高级的功能,也可能打开JavaScript

To have more advanced functionality, you should use a QWebPluginFactory

要获得更高级的功能,您应该使用QWebPluginFactory

#2


1  

Actually Webkit has been intregated in Qt and this intregated package is called QtWebkit. And they have provided new method for for plugin creation.I just need a link or steps for creating a plugin in QtWebkit and that plugin should be invoked by java script.

实际上Webkit已经在Qt中被集成,这个被嵌入的包被称为QtWebkit。并且它们为插件创建提供了新方法。我只需要一个或多个链接来在QtWebkit中创建插件,该插件应该由java脚本调用。

Regards Vivek Gupta

关心Vivek Gupta

#3


0  

Introduction to WebKit Plug-in Programming Topics is for WebKit, is QtWebKit that special?

WebKit简介插件编程主题是针对WebKit的,QtWebKit是特别的吗?

#4


0  

To expose the object to Javascript, use

要将对象公开给Javascript,请使用

this->mainFrame()->addToJavaScriptWindowObject("lineedit", this);

where lineedit is the name that can be used to access the object from javascript

其中lineedit是可用于从javascript访问对象的名称

Qt properties will be exposed as JavaScript properties and slots as JavaScript methods. (see http://doc.qt.io/archives/qt-4.7/qwebframe.html#addToJavaScriptWindowObject)

Qt属性将作为JavaScript属性和插槽显示为JavaScript方法。 (参见http://doc.qt.io/archives/qt-4.7/qwebframe.html#addToJavaScriptWindowObject)