QWebView:How to open link in an extern browser

I have got some problem with QWebView when I tried to open link in an extern browser(Such as FireFox). here is the solution I came up with:

void SomeClass::someFunction()
{
	QWebView *view = new QWebView(this);
	view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
	connect( view->page(), SIGNAL(linkClicked(const QUrl &)),
		this, SLOT(newsOnLinkClicked(const QUrl &)));
	view->load(QUrl(url));
	view->show();
}

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

Related posts:

  1. how to sort CAtlArray using qsort
  2. 100 Open Source Web Design Tools, Resources, and Template Repositories
  3. Open Office无法正常启动的问题

Related posts:


Leave a comment


(will not be published)