Ok I managed to make it work (I guess my brain was tired yesterday).
//myqwebpage.h
#ifndef MYQWEBPAGE_H
#define MYQWEBPAGE_H
#include <QObject>
#include <QWebPage>
class MyQWebPage : public QWebPage
{
Q_OBJECT
public:
protected:
#if QT_VERSION >= 0x040400
bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type);
#else
bool acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, NavigationType type);
#endif
signals:
#if QT_VERSION >= 0x040400
void formSubmitted(const QNetworkRequest &request);
#else
void formSubmitted(const QWebNetworkRequest &request);
#endif
};
#endif // MYQWEBPAGE_H
//myqwebpage.h
#ifndef MYQWEBPAGE_H
#define MYQWEBPAGE_H
#include <QObject>
#include <QWebPage>
class MyQWebPage : public QWebPage
{
Q_OBJECT
public:
MyQWebPage(QObject *parent=0);
protected:
#if QT_VERSION >= 0x040400
bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type);
#else
bool acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, NavigationType type);
#endif
signals:
#if QT_VERSION >= 0x040400
void formSubmitted(const QNetworkRequest &request);
#else
void formSubmitted(const QWebNetworkRequest &request);
#endif
};
#endif // MYQWEBPAGE_H
To copy to clipboard, switch view to plain text mode
// myqwebpage.cpp
#include <QtGui>
#include "myqwebpage.h"
MyQWebPage
::MyQWebPage(QObject *parent
): QWebPage
(parent
){}
#if QT_VERSION >= 0x040400
bool MyQWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
#else
bool MyQWebPage::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
#endif
{
if (type == NavigationTypeFormSubmitted) {
emit formSubmitted(request);
return false;
}
return QWebPage::acceptNavigationRequest(frame,request,type);
}
// myqwebpage.cpp
#include <QtGui>
#include "myqwebpage.h"
MyQWebPage::MyQWebPage(QObject *parent): QWebPage(parent){
}
#if QT_VERSION >= 0x040400
bool MyQWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
#else
bool MyQWebPage::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
#endif
{
if (type == NavigationTypeFormSubmitted) {
emit formSubmitted(request);
return false;
}
return QWebPage::acceptNavigationRequest(frame,request,type);
}
To copy to clipboard, switch view to plain text mode
then finaly I connect the signal to a slot
#if QT_VERSION >= 0x040400
connect(webpage,SIGNAL(formSubmitted(const QNetworkRequest&)),this,SLOT(OnFormSubmitted(const QNetworkRequest&)));
#else
connect(webpage,SIGNAL(formSubmitted(const QWebNetworkRequest&)),this,SLOT(OnFormSubmitted(const QWebNetworkRequest&)));
#endif
#if QT_VERSION >= 0x040400
connect(webpage,SIGNAL(formSubmitted(const QNetworkRequest&)),this,SLOT(OnFormSubmitted(const QNetworkRequest&)));
#else
connect(webpage,SIGNAL(formSubmitted(const QWebNetworkRequest&)),this,SLOT(OnFormSubmitted(const QWebNetworkRequest&)));
#endif
To copy to clipboard, switch view to plain text mode
thx for your help.
Bookmarks