本文整理汇总了C++中QWebFrame::hitTestContent方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebFrame::hitTestContent方法的具体用法?C++ QWebFrame::hitTestContent怎么用?C++ QWebFrame::hitTestContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebFrame
的用法示例。
在下文中一共展示了QWebFrame::hitTestContent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseMoveEvent
void EWAHTMLSelector::mouseMoveEvent( QMouseEvent *event )
{
if( !m_webViewPtr )
{
return;
}
QPoint pnt = mapFromGlobal( event->globalPos() );
QWebFrame *pFrame = m_webViewPtr->page()->frameAt( pnt );
if( pFrame )
{
QWebElement element = pFrame->hitTestContent( m_webViewPtr->mapFromGlobal( event->globalPos() ) ).element();
if( m_element != element )
{
m_element = element;
update();
QString str = tr( "Inner xml: %1\nOuter xml: %2\nPlain text: %3" )
.arg( m_element.toInnerXml() )
.arg( m_element.toOuterXml() )
.arg( m_element.toPlainText() );
emit signalHtmlElement( str );
}
}
}
示例2: while
QWebFrame *QtScrollerFilter::scrollingFrameAt_QWebView(QWebView *view, const QPoint &pos) const
{
if (!view->page())
return 0;
QWebFrame *mainFrame = view->page()->mainFrame();
QWebHitTestResult hitTest = mainFrame->hitTestContent(pos);
QWebFrame *hitFrame = hitTest.frame();
if (!hitFrame)
return 0;
QRect vsbrect = hitFrame->scrollBarGeometry(Qt::Vertical);
QRect hsbrect = hitFrame->scrollBarGeometry(Qt::Horizontal);
if (!vsbrect.isEmpty() && vsbrect.contains(hitTest.pos() - hitFrame->scrollPosition()))
return 0;
if (!hsbrect.isEmpty() && hsbrect.contains(hitTest.pos() - hitFrame->scrollPosition()))
return 0;
QSize range = hitFrame->contentsSize() - hitFrame->geometry().size();
while (hitFrame && range.width() <= 1 && range.height() <= 1)
hitFrame = hitFrame->parentFrame();
return hitFrame;
}
示例3: clickedLink
QUrl WebView::clickedLink(const QPoint &pos) const
{
QWebFrame *frame = page()->frameAt(pos);
if (!frame)
return QUrl();
return frame->hitTestContent(pos).linkUrl();
}
示例4: hitTestContent
QWebHitTestResult QWebFrameProto::hitTestContent(const QPoint & pos) const
{
scriptDeprecated("QWebFrame will not be available in future versions");
QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
if (item)
return item->hitTestContent(pos);
return QWebHitTestResult();
}
示例5: scrollingFrameAt
// Returns the innermost frame at the given position that can scroll.
QWebFrame* scrollingFrameAt(const QPoint& pos) const
{
QWebFrame* hitFrame = 0;
if (m_view) {
QWebFrame* frame = m_view->page()->mainFrame();
hitFrame = frame->hitTestContent(pos).frame();
QSize range = hitFrame->contentsSize() - hitFrame->geometry().size();
while (hitFrame && range.width() <= 1 && range.height() <= 1)
hitFrame = hitFrame->parentFrame();
return hitFrame;
}
}
示例6: findElement
void ClickToFlash::findElement()
{
if (!loadButton_)
return;
QPoint objectPos = page_->view()->mapFromGlobal(loadButton_->mapToGlobal(loadButton_->pos()));
QWebFrame* objectFrame = page_->frameAt(objectPos);
QWebHitTestResult hitResult;
QWebElement hitElement;
if (objectFrame) {
hitResult = objectFrame->hitTestContent(objectPos);
hitElement = hitResult.element();
}
if (!hitElement.isNull() && (hitElement.tagName().compare("embed", Qt::CaseInsensitive) == 0 ||
hitElement.tagName().compare("object", Qt::CaseInsensitive) == 0)) {
element_ = hitElement;
return;
}
// HitTestResult failed, trying to find element by src
// attribute in elements at all frames on page (less accurate)
QList<QWebFrame*> frames;
frames.append(objectFrame);
frames.append(page_->mainFrame());
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
if (!frame) {
continue;
}
QWebElement docElement = frame->documentElement();
QWebElementCollection elements;
elements.append(docElement.findAll(QLatin1String("embed")));
elements.append(docElement.findAll(QLatin1String("object")));
foreach (const QWebElement &element, elements) {
if (!checkElement(element) && !checkUrlOnElement(element)) {
continue;
}
element_ = element;
return;
}
frames += frame->childFrames();
}
}
示例7: slotLinkHovered
void KWebKitPart::slotLinkHovered(const QString& _link, const QString& /*title*/, const QString& /*content*/)
{
QString message;
if (_link.isEmpty()) {
message = QL1S("");
emit m_browserExtension->mouseOverInfo(KFileItem());
} else {
QUrl linkUrl (_link);
const QString scheme = linkUrl.scheme();
// Protect the user against URL spoofing!
linkUrl.setUserName(QString());
const QString link (linkUrl.toString());
if (QString::compare(scheme, QL1S("mailto"), Qt::CaseInsensitive) == 0) {
message += i18nc("status bar text when hovering email links; looks like \"Email: [email protected] - CC: [email protected] -BCC: [email protected] - Subject: Hi translator\"", "Email: ");
// Workaround: for QUrl's parsing deficiencies of "mailto:[email protected]".
if (!linkUrl.hasQuery())
linkUrl = QUrl(scheme + '?' + linkUrl.path());
QMap<QString, QStringList> fields;
QList<QPair<QString, QString> > queryItems = linkUrl.queryItems();
const int count = queryItems.count();
for(int i = 0; i < count; ++i) {
const QPair<QString, QString> queryItem (queryItems.at(i));
//kDebug() << "query: " << queryItem.first << queryItem.second;
if (queryItem.first.contains(QL1C('@')) && queryItem.second.isEmpty())
fields["to"] << queryItem.first;
if (QString::compare(queryItem.first, QL1S("to"), Qt::CaseInsensitive) == 0)
fields["to"] << queryItem.second;
if (QString::compare(queryItem.first, QL1S("cc"), Qt::CaseInsensitive) == 0)
fields["cc"] << queryItem.second;
if (QString::compare(queryItem.first, QL1S("bcc"), Qt::CaseInsensitive) == 0)
fields["bcc"] << queryItem.second;
if (QString::compare(queryItem.first, QL1S("subject"), Qt::CaseInsensitive) == 0)
fields["subject"] << queryItem.second;
}
if (fields.contains(QL1S("to")))
message += fields.value(QL1S("to")).join(QL1S(", "));
if (fields.contains(QL1S("cc")))
message += i18nc("status bar text when hovering email links; looks like \"Email: [email protected] - CC: [email protected] -BCC: [email protected] - Subject: Hi translator\"", " - CC: ") + fields.value(QL1S("cc")).join(QL1S(", "));
if (fields.contains(QL1S("bcc")))
message += i18nc("status bar text when hovering email links; looks like \"Email: [email protected] - CC: [email protected] -BCC: [email protected] - Subject: Hi translator\"", " - BCC: ") + fields.value(QL1S("bcc")).join(QL1S(", "));
if (fields.contains(QL1S("subject")))
message += i18nc("status bar text when hovering email links; looks like \"Email: [email protected] - CC: [email protected] -BCC: [email protected] - Subject: Hi translator\"", " - Subject: ") + fields.value(QL1S("subject")).join(QL1S(" "));
} else if (scheme == QL1S("javascript")) {
message = KStringHandler::rsqueeze(link, 150);
if (link.startsWith(QL1S("javascript:window.open")))
message += i18n(" (In new window)");
} else {
message = link;
QWebFrame* frame = page() ? page()->currentFrame() : 0;
if (frame) {
QWebHitTestResult result = frame->hitTestContent(page()->view()->mapFromGlobal(QCursor::pos()));
QWebFrame* target = result.linkTargetFrame();
if (frame->parentFrame() && target == frame->parentFrame()) {
message += i18n(" (In parent frame)");
} else if (!target || target != frame) {
message += i18n(" (In new window)");
}
}
KFileItem item (linkUrl, QString(), KFileItem::Unknown);
emit m_browserExtension->mouseOverInfo(item);
}
}
emit setStatusBarText(message);
}
示例8: eventFilter
bool MyWebView::eventFilter(QObject *watched, QEvent *event)
{
if (!m_boolEnableEvtProcess) { return false; }
if (event->type() == QEvent::MouseMove)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
QWebView *view = dynamic_cast<QWebView*>(watched);
QPoint pos = view->mapFromGlobal(mouseEvent->globalPos());
QWebFrame *frame = view->page()->frameAt(mouseEvent->pos());
if (frame!=NULL)
{
QWebHitTestResult hitTestResult = frame->hitTestContent(pos);
// if the hovered elem is not the same as the previously hovered
if (hitTestResult.element() != m_old_hover_element)
{
QWebElement elemCurrent = hitTestResult.element();
// if dragging, overwrite with closer WContainer
if (m_boolIsDraggingWidget)
{
elemCurrent = FindCloserContainer(elemCurrent);
}
if (!elemCurrent.isNull())
{
// Change color
ChangeHoveredElemColor(elemCurrent);
// Message to print
m_strCurrentElemId = elemCurrent.attribute("id");
// Emit message
QStringList strlistClasses = elemCurrent.classes();
strlistClasses.removeAll(g_strHighlightClassName);
Q_EMIT mouseMovedOverElem(m_strCurrentElemId, strlistClasses.join(' '));
}
}
}
}
else if (event->type() == QEvent::MouseButtonPress)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::LeftButton)
{
QWebView *view = dynamic_cast<QWebView*>(watched);
QPoint pos = view->mapFromGlobal(mouseEvent->globalPos());
QWebFrame *frame = view->page()->frameAt(mouseEvent->pos());
if (frame != NULL)
{
QWebHitTestResult hitTestResult = frame->hitTestContent(pos);
QWebElement welemTemp = hitTestResult.element();
QWebElement elemCurrent = FindCloserWidget(welemTemp);
// if the clicked elem is not the same as the previously clicked
if (elemCurrent != m_old_click_element)
{
// Change color
ChangeClickedElemColor(elemCurrent);
// Message to print
m_strCurrentElemId = elemCurrent.attribute("id");
// Emit message
Q_EMIT mouseLeftClickedOverElem(m_strCurrentElemId);
}
}
}
}
return false;
}
示例9: findElement
void ClickToFlash::findElement()
{
if (!m_toolButton) {
return;
}
QWidget* parent = parentWidget();
QWebView* view = 0;
while (parent) {
if (QWebView* aView = qobject_cast<QWebView*>(parent)) {
view = aView;
break;
}
parent = parent->parentWidget();
}
if (!view) {
return;
}
QPoint objectPos = view->mapFromGlobal(m_toolButton->mapToGlobal(m_toolButton->pos()));
QWebFrame* objectFrame = view->page()->frameAt(objectPos);
QWebHitTestResult hitResult;
QWebElement hitElement;
if (objectFrame) {
hitResult = objectFrame->hitTestContent(objectPos);
hitElement = hitResult.element();
}
if (!hitElement.isNull() && (hitElement.tagName().compare("embed", Qt::CaseInsensitive) == 0 ||
hitElement.tagName().compare("object", Qt::CaseInsensitive) == 0)) {
m_element = hitElement;
return;
}
// HitTestResult failed, trying to find element by src
// attribute in elements at all frames on page (less accurate)
QList<QWebFrame*> frames;
frames.append(objectFrame);
m_mainFrame = view->page()->mainFrame();
frames.append(m_mainFrame);
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
if (!frame) {
continue;
}
QWebElement docElement = frame->documentElement();
QWebElementCollection elements;
elements.append(docElement.findAll(QLatin1String("embed")));
elements.append(docElement.findAll(QLatin1String("object")));
foreach(const QWebElement & element, elements) {
if (!checkElement(element) && !checkUrlOnElement(element)) {
continue;
}
m_element = element;
return;
}
frames += frame->childFrames();
}
}
示例10: performHitTest
QWebHitTestResult WebkitPixelStreamer::performHitTest(const deflect::Event &dcEvent) const
{
const QPoint& pointerPos = getPointerPosition(dcEvent);
QWebFrame *pFrame = webView_.page()->frameAt(pointerPos);
return pFrame ? pFrame->hitTestContent(pointerPos) : QWebHitTestResult();
}