Vivek Gupta
Vivek Gupta

Reputation:

How do I develop a plug-in for 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

Upvotes: 2

Views: 4674

Answers (4)

Henrik Hartz
Henrik Hartz

Reputation: 3675

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 &paramNames, const QStringList &paramValues)
   {
      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

Upvotes: 4

Kurt Pattyn
Kurt Pattyn

Reputation: 2788

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)

Upvotes: 0

Vivek Gupta
Vivek Gupta

Reputation:

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

Upvotes: 1

Eugene Yokota
Eugene Yokota

Reputation: 95614

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

Upvotes: 0

Related Questions