Trying to issue a mouseclick event on a QWebElement in QWebView QtWebKit

Posted by Bad Man on Stack Overflow See other posts from Stack Overflow or by Bad Man
Published on 2010-04-09T18:30:52Z Indexed on 2010/04/09 18:33 UTC
Read the original article Hit count: 606

Filed under:
|
|

I'm trying to send a mouse click event on a certain element in the QtWebKit DOM but I'm obviously doing it wrong:

QWebElement el=this->page()->mainFrame()->findFirstElement("input[type=submit]");
el.setFocus();

QMouseEvent pressEvent(QMouseEvent::MouseButtonPress, el.geometry().center(),
                    Qt::MouseButton::LeftButton, Qt::LeftButton, Qt::NoModifier);
QCoreApplication::sendEvent(this->page()->mainFrame(), &pressEvent);

QMouseEvent releaseEvent(QMouseEvent::MouseButtonRelease, el.geometry().center(),
                    Qt::MouseButton::LeftButton, Qt::LeftButton, Qt::NoModifier);

QCoreApplication::sendEvent(this->page()->mainFrame(), &releaseEvent);

Any ideas?

(p.s. I am extending QWebView if it wasn't obvious)

© Stack Overflow or respective owner

Related posts about qt

Related posts about c++