What exactly is the problem? What errors are you getting?
Hi Wysota,
Thanks for the reply. I have solved the linking errors but I need to know how to navigate pages within a iframe or frameset rather than the top main frame. As far as I understand then I am supposed to over ride navigation request in the subclassed QWebView something like:
bool MyWebView::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
{
//Q_UNUSED(frame)
if (type == NavigationTypeLinkClicked) {
switch (d->linkPolicy) {
case DontDelegateLinks:
return true;
case DelegateExternalLinks:
if (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLo cal(request.url().scheme()))
return true;
emit linkClicked(request.url());
return false;
case DelegateAllLinks:
emit linkClicked(request.url());
frame->load(QUrl("http://www.google.com/")); // Need to analyse first
qDebug() << "LINK HAS BEEN CLICKED";
return true;
}
}
return true;
}
It is obviously wrong as I will get all sorts of errors such as:
"error: use of undeclared identifier 'NavigationTypeLinkClicked'
if (type == NavigationTypeLinkClicked) {
^"
and
"error: 'd' is a private member of 'QWebView'
switch (d->linkPolicy) {"
and
"error: member access into incomplete type 'QWebViewPrivate'
switch (d->linkPolicy) {
^
^"
So I need an overview or quick example of how to cater for iframe navigation in a subclassed QWebView.
FYI
I have subclassed a QWebPag to specify a specific useragent and that works OK.
I'm sure newbies would appreciate a full example of navigating within iframes as other solutions just state override the acceptNavigationRequest method to access the specific frame.
Regards & Thanks
I'm not sure what the problem is... The web frame is the method's parameter, you can access it there...
Wysota,
First of all - thanks for your time, appreciated! I've made some progress.
I have a subclassed QWebPage
I have this:
*****************
bool MyCustomWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
{
if (frame->parentFrame() != 0){
if (type == NavigationTypeLinkClicked) {
//frame->setUrl(request.url()); // THIS FAILS
frame->setUrl(QUrl("http://www.google.co.uk")); // this works now and changes the URL in the frame
// I Need to analyse the querystring parameters first
}
}
qDebug() << "LINK HAS BEEN CLICKED"; // Just Checking where I am
return true;
}
******************
Note this works with no setLinkDelegationPolicy(QWebPage:elegateAllLinks); NOT being set
Notice that:
frame->setUrl(request.url()); // THIS FAILS
With
error: member access into incomplete type 'const QNetworkRequest'
frame->setUrl(request.url()); // Need to analyse first
^
on the setUrl() method
So
a) I need to analyse the url
b) I need to shut of that error
Thanks in advance.
Regards
Qt Code:
#include <QNetworkRequest>To copy to clipboard, switch view to plain text mode
BTW. Please use the [code] tags.
Wysota,
Bingo! That does the job nicely. Thank you.
Point taken on the code tags.
Bookmarks