当前位置: 首页>>代码示例>>C++>>正文


C++ QWebHitTestResult::linkElement方法代码示例

本文整理汇总了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) );
}
开发者ID:DSastre,项目名称:supercollider,代码行数:33,代码来源:help_browser.cpp

示例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() );
}
开发者ID:DSastre,项目名称:supercollider,代码行数:26,代码来源:QcWebView.cpp

示例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;
}
开发者ID:marado,项目名称:snowglobe,代码行数:70,代码来源:llwebpage.cpp


注:本文中的QWebHitTestResult::linkElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。