[quote author="Gianluca" date="1408976181"]Can you post the code on how to wrap a QWebView to qml ??
I have the same problem, but I don't know how to wrap a QWebView into qml[/quote]
You can do it in this way:(from qt 4.8 source code,it's compatible with 4.8/5.3)
@#include "qdeclarativewebview_p.h"
#include <QtCore/QDebug>
#include <QtCore/QEvent>
#include <QtCore/QFile>
#include <QtDeclarative/QDeclarativeContext>
#include <QtDeclarative/QDeclarativeEngine>
#include <QtDeclarative/qdeclarative.h>
#include <QtGui/QApplication>
#include <QtGui/QGraphicsSceneMouseEvent>
#include <QtGui/QKeyEvent>
#include <QtGui/QMouseEvent>
#include <QtGui/QPen>
#include "qwebelement.h"
#include "qwebframe.h"
#include "qwebpage.h"
#include "qwebsettings.h"
QT_BEGIN_NAMESPACE
class QDeclarativeWebViewPrivate {
public:
QDeclarativeWebViewPrivate(QDeclarativeWebView* qq)
: q(qq)
, preferredwidth(0)
, preferredheight(0)
, progress(1.0)
, status(QDeclarativeWebView::Null)
, pending(PendingNone)
, newWindowComponent(0)
, newWindowParent(0)
, rendering(true)
{
}
QDeclarativeWebView* q;
QUrl url; // page url might be different if it has not loaded yet
GraphicsWebView* view;
int preferredwidth, preferredheight;
qreal progress;
QDeclarativeWebView::Status status;
QString statusText;
enum { PendingNone, PendingUrl, PendingHtml, PendingContent } pending;
QUrl pendingUrl;
QString pendingString;
QByteArray pendingData;
mutable QDeclarativeWebSettings settings;
QDeclarativeComponent* newWindowComponent;
QDeclarativeItem* newWindowParent;
static void windowObjectsAppend(QDeclarativeListProperty<QObject>* prop, QObject* o)
{
static_cast<QDeclarativeWebViewPrivate*>(prop->data)->windowObjects.append(o);
static_cast<QDeclarativeWebViewPrivate*>(prop->data)->updateWindowObjects();
}
void updateWindowObjects();
QObjectList windowObjects;
bool rendering;
};
void QDeclarativeWebView::init()
{
d = new QDeclarativeWebViewPrivate(this);
if (QWebSettings::iconDatabasePath().isNull() &&
QWebSettings::globalSettings()->localStoragePath().isNull() &&
QWebSettings::offlineStoragePath().isNull() &&
QWebSettings::offlineWebApplicationCachePath().isNull())
QWebSettings::enablePersistentStorage();
setAcceptedMouseButtons(Qt::LeftButton);
setFlag(QGraphicsItem::ItemHasNoContents, true);
setFlag(QGraphicsItem::ItemIsFocusScope, true);
setClip(true);
d->view = new GraphicsWebView(this);
d->view->setResizesToContents(true);
d->view->setFocus();
QWebPage* wp = new QDeclarativeWebPage(this);
setPage(wp);
if (!preferredWidth())
setPreferredWidth(d->view->preferredWidth());
if (!preferredHeight())
setPreferredHeight(d->view->preferredHeight());
connect(d->view, SIGNAL(geometryChanged()), this, SLOT(updateDeclarativeWebViewSize()));
connect(d->view, SIGNAL(doubleClick(int, int)), this, SIGNAL(doubleClick(int, int)));
connect(d->view, SIGNAL(scaleChanged()), this, SIGNAL(contentsScaleChanged()));
}@
There two file name as you need in qt 4.8 source code:
qdeclarativewebview.cpp
qdeclarativewebview_p.h
You should check on that and build your own wrapper