Qtwebkit plugin
-
Hi,
I tried to create a QtWebkit plugin using QWebPage::createPlugin, but seems there is something wrong. The output is only a nullplugicon !http://opensource.apple.com/source/WebCore/WebCore-528.14/Resources/nullPlugin.png(nullplugin icon)!
I put the plugin dll in the application.exe's folder.following is my code
plugin dll@
#ifndef PLUGINPAGE_H
#define PLUGINPAGE_H#include "pluginpage_global.h"
#include <QWebPage>
#include <QtGui>class PLUGINPAGE_EXPORT PluginPage : public QWebPage
{
public:
PluginPage(QObject *parent = 0)
: QWebPage(parent) {}
protected:
virtual QObject *createPlugin(const QString &classid, const QUrl &url,
const QStringList ¶mNames,
const QStringList ¶mValues)
{
QObject *result = 0;
if (classid == "pushbutton")
result = new QPushButton();
else if (classid == "lineedit")
result = new QLineEdit();
if (result)
result->setObjectName(classid);
return result;
}
};
#endif // PLUGINPAGE_H
@html
<html>
<body>
<object type='application/x-qt-plugin' classid='pushbutton' id='mybutton'/>
</body>
</html>application
@
#include "qtwebkitapp.h"
#include <QtGui>
#include <QtWebKit>QtWebkitApp::QtWebkitApp(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);QString titleQString = QString("test"); QUrl url = QUrl(QString("http://127.0.0.1:8000/pluginpage.htm")); QNetworkProxyFactory::setUseSystemConfiguration(true); view = new QWebView(this); view->settings()->setAttribute(QWebSettings::JavascriptEnabled, true); view->settings()->setAttribute(QWebSettings::PluginsEnabled, true); view->load(url); setCentralWidget(view);
}
@