如何为 QtWebKit 开发插件?

发布于 2024-07-09 07:50:33 字数 261 浏览 18 评论 0原文

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

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

-问候,维韦克·古普塔

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?

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

-Regards, Vivek Gupta

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

向地狱狂奔 2024-07-16 07:50:33

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

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

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

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

请记住,如果您想要 QWebSettings

要拥有更高级的功能,您应该使用 QWebPluginFactory

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;

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

and show something like the following HTML;

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

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

To have more advanced functionality, you should use a QWebPluginFactory

生来就爱笑 2024-07-16 07:50:33

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

问候
维韦克·古普塔

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.

Regards
Vivek Gupta

瑶笙 2024-07-16 07:50:33

WebKit 插件编程主题简介适用于 WebKit, QtWebKit 有那么特别吗?

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

红尘作伴 2024-07-16 07:50:33

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

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

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

属性将公开为 JavaScript 属性,插槽将公开为 JavaScript 方法。
(参见http://doc.qt.io/archives/qt-4.7 /qwebframe.html#addToJavaScriptWindowObject)

To expose the object to Javascript, use

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

where lineedit is the name that can be used to access the object from 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文