I'm having trouble detecting the clicked element in a qtwebkit qwebview.
Don't know why but when looking for an attribute, I get nothing back when clicking on text in my document
void APP_Orders::contextMenuEvent(QContextMenuEvent *event)
{
QWebHitTestResult hit = page()->mainFrame()->hitTestContent(event->pos());
QWebElement hitElement = hit.element();
QString ctx = hitElement.attribute("ctx","none");
while(ctx == "none")
{
hitElement = hitElement.parent();
ctx = hitElement.attribute("ctx","none");
}
qDebug() << ctx;
}
In my document, I have a ctx attribute on the body. Wherever I click, I get the body's ctx attribute in the debug that's the expected behaviour but when I click on text, It looks like it's not in the document... the app crashes after being in an infinite loop. even when I look at the xml content or parents, grandparents grangranparents xml content is always an empty string...
Any idea why???