[Interest] How to find QWebElement at clickposition?
Wilhelm
wilhelm.meier at fh-kl.de
Thu Feb 7 07:02:28 CET 2013
Hi all,
I try to find the QWebElement at the clickposition in a QWebView
(Qt-5.0) witch the follwing code snippet:
void WebView::mousePressEvent(QMouseEvent *e)
{
QWebFrame* frame = page()->frameAt(e->pos());
QWebHitTestResult hit = frame->hitTestContent(e->pos());
qDebug() << Q_FUNC_INFO << e->pos()
<< hit.element().toOuterXml()
;
QWebView::mousePressEvent(e);
}
WebView is a direct subclass of QWebView.
The result is not what I expected; maybe my expection is wrong :-)
- if I click right beside the element (e.g. <p>), I get the "correct"
element
- if I click on the element, I get an empty QWebElement
- if I click left beside the element, I get the whole webpage.
What am I doing wrong?
--
Wilhelm
More information about the Interest
mailing list