PDA

View Full Version : Problem With QWebView



ivi2501
20th March 2008, 22:35
Hi.
I have problem with QWebView (QWebPage)

Need make script for load html page like:



QWebView * view = new QWebView();
connect(view, SIGNAL(linkClicked ( const QUrl & )), this, SLOT(newsOnLinkClicked ( const QUrl & )));
view->load(QUrl("http://newsroot.net"));
view->show();

Works fine.
Problem there need open all links in default browser like Firefox or IE.

I try all settings.

QWebPage * wpage = new QWebPage ();
connect(wpage, SIGNAL(linkClicked ( const QUrl & )), this, SLOT(newsOnLinkClicked ( const QUrl & )));
wpage->setLinkDelegationPolicy (QWebPage::DelegateAllLinks);
QWebView * view = new QWebView();
wpage->triggerAction(QWebPage::OpenLink,true);
view->triggerPageAction(QWebPage::OpenLink,true);
connect(view, SIGNAL(linkClicked ( const QUrl & )), this, SLOT(newsOnLinkClicked ( const QUrl & )));
wpage->setView(view);
view->load(QUrl("http://newsroot.net"));
view->show();

Possible some lines not need.

Please help.
;)

jacek
21st March 2008, 11:05
How did you implement newsOnLinkClicked() slot?

ivi2501
21st March 2008, 12:48
I can't disable follow links in QWebView too.

-----------------------------

Window.h


public slots:
void newsOnLinkClicked ( const QUrl & );

Window.cpp


void Window::newsOnLinkClicked ( const QUrl & url )
{
QDesktopServices::openUrl(url);
}

jacek
21st March 2008, 14:00
I can't disable follow links in QWebView too.
Do I understand correctly that all links are opened both in external browser and QWebView?

ivi2501
21st March 2008, 14:04
All links must be opened in external browser.
I have site, need make software api for this site.
My Sites:
http://admintools.org.ua
http://newsroot.net

jacek
21st March 2008, 14:05
How about this?
QWebView * view = new QWebView();
connect( view, SIGNAL(linkClicked( const QUrl & )), this, SLOT(newsOnLinkClicked( const QUrl & )) );
view->load( QUrl( "http://newsroot.net" ) );
view->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
view->show();

ivi2501
21st March 2008, 14:13
Nice !!!!!!!!!!
Works fine.
Thank You :)
:)

ivi2501
24th August 2008, 01:07
Please help with another problem.


I need disable context menu for QWebView

maddog_fr
2nd August 2009, 19:37
view->setContextMenuPolicy(Qt::NoContextMenu);