本文整理汇总了C++中QWebHitTestResult::linkElement方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebHitTestResult::linkElement方法的具体用法?C++ QWebHitTestResult::linkElement怎么用?C++ QWebHitTestResult::linkElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebHitTestResult
的用法示例。
在下文中一共展示了QWebHitTestResult::linkElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onContextMenuRequest
void HelpBrowser::onContextMenuRequest( const QPoint & pos )
{
QMenu menu;
QWebHitTestResult hitTest = mWebView->page()->mainFrame()->hitTestContent( pos );
if (!hitTest.linkElement().isNull()) {
menu.addAction( mWebView->pageAction(QWebPage::CopyLinkToClipboard) );
}
menu.addSeparator();
if (hitTest.isContentEditable() || hitTest.isContentSelected())
menu.addAction( mWebView->pageAction(QWebPage::Copy) );
if (hitTest.isContentEditable())
menu.addAction( mWebView->pageAction(QWebPage::Paste) );
if (hitTest.isContentSelected())
menu.addAction( mActions[Evaluate] );
menu.addSeparator();
menu.addAction( mWebView->pageAction(QWebPage::Back) );
menu.addAction( mWebView->pageAction(QWebPage::Forward) );
menu.addAction( mWebView->pageAction(QWebPage::Reload) );
menu.addSeparator();
menu.addAction( mActions[ZoomIn] );
menu.addAction( mActions[ZoomOut] );
menu.addAction( mActions[ResetZoom] );
menu.exec( mWebView->mapToGlobal(pos) );
}
示例2: contextMenuEvent
void WebView::contextMenuEvent ( QContextMenuEvent * event )
{
QMenu menu;
QPoint pos = event->pos();
QWebHitTestResult hitTest = page()->mainFrame()->hitTestContent( pos );
if (!hitTest.linkElement().isNull()) {
menu.addAction( pageAction(QWebPage::CopyLinkToClipboard) );
menu.addSeparator();
}
if (hitTest.isContentEditable() || hitTest.isContentSelected()) {
menu.addAction( pageAction(QWebPage::Copy) );
if (hitTest.isContentEditable())
menu.addAction( pageAction(QWebPage::Paste) );
menu.addSeparator();
}
menu.addAction( pageAction(QWebPage::Back) );
menu.addAction( pageAction(QWebPage::Forward) );
menu.addAction( pageAction(QWebPage::Reload) );
menu.exec( event->globalPos() );
}
示例3: acceptNavigationRequest
bool LLWebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, NavigationType type)
{
if (!window)
return false;
if (request.url().scheme() == window->d->mNoFollowScheme)
{
QString encodedUrl = request.url().toEncoded();
// QUrl is turning foo:///home/bar into foo:/home/bar for some reason while Firefox does not
// http://bugs.webkit.org/show_bug.cgi?id=24695
if (!encodedUrl.startsWith(window->d->mNoFollowScheme + "://")) {
encodedUrl = encodedUrl.mid(window->d->mNoFollowScheme.length() + 1);
encodedUrl = window->d->mNoFollowScheme + "://" + encodedUrl;
}
std::string rawUri = encodedUrl.toStdString();
LLEmbeddedBrowserWindowEvent event(window->getWindowId(), rawUri, rawUri);
window->d->mEventEmitter.update(&LLEmbeddedBrowserWindowObserver::onClickLinkNoFollow, event);
return false;
}
bool accepted = QWebPage::acceptNavigationRequest(frame, request, type);
if (accepted && type == QWebPage::NavigationTypeLinkClicked)
{
// save URL
QUrl url = request.url();
window->d->mClickHref = QString(url.toEncoded()).toStdString();
// save target attribute
QWebHitTestResult hitTest = mainFrame()->hitTestContent(currentPoint);
QString linkTarget = hitTest.linkElement().attribute("target");
window->d->mClickTarget = linkTarget.toStdString();
// start off with no target specified
int link_target_type = LLQtWebKit::LTT_TARGET_UNKNOWN;
// user clicks on a link with a target that matches the one set as "External"
if ( window->d->mClickTarget.empty() )
{
link_target_type = LLQtWebKit::LTT_TARGET_NONE;
}
else
if ( window->d->mClickTarget == window->d->mExternalTargetName )
{
link_target_type = LLQtWebKit::LTT_TARGET_EXTERNAL;
}
else
// user clicks on a link with a target that matches the one set as "Blank"
if ( window->d->mClickTarget == window->d->mBlankTargetName )
{
link_target_type = LLQtWebKit::LTT_TARGET_BLANK;
}
else
{
// default action for a target we haven't specified is to open in current window
// and fire an event as if it was a normal click
window->navigateTo( window->d->mClickHref );
link_target_type = LLQtWebKit::LTT_TARGET_OTHER;
};
// build event based on the data we have and emit it
LLEmbeddedBrowserWindowEvent event( window->getWindowId(),
window->getCurrentUri(),
window->d->mClickHref,
window->d->mClickTarget,
link_target_type );
window->d->mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onClickLinkHref, event );
};
return accepted;
}