How do I develop a plugin for QtWebKit?

I am trying to develop a plugin for QtWebkit . But I can't find how to develop a plugin for QtWebKit, hopefully one that can be called by JavaScript. Does anyone know of any tutorials or docs that explain how to do this?

Webkit has been included with Qt and this integrated package is called QtWebkit. They provided a new method for creating plugins.

-Regards, Vivek Gupta

+1


source to share


4 answers


The simple answer is to subclass QWebPage and set it to webview. You can then display your own HTML page and respond 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 enable plugins and possibly JavaScript if you want more advanced features in QWebSettings

To have more advanced features, you must use QWebPluginFactory

+4


source


In fact, Webkit was included with Qt, and this package is internally named QtWebkit. And they provided a new method for creating plugins. I just need a link or steps to create a plugin in QtWebkit and this plugin needs to be called by a java script.



Vivek Gupta's relationship

+1


source


Introduction to WebKit Plugin Programming Topics for WebKit - is it a special QtWebKit?

0


source


To open an object in 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 appear as JavaScript properties and slots as JavaScript methods. (see http://doc.qt.io/archives/qt-4.7/qwebframe.html#addToJavaScriptWindowObject )

0


source







All Articles