Despite the fact that the initial question is one year old, it is still relevant for those who, like me, decided to move (finally!) From QWebKit to QWebEngine (Qt 5.5 - 5.6b). Here is a dirty solution that requires an existing webenginepage-> view (). This is for mouse events, and it would not be a big surprise if it were not located for keyboard events:
void Whatever::sendMouseEvent( QObject* targetObj, QMouseEvent::Type type, const QPoint& pnt ) const { QMouseEvent event( type, pnt, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); QApplication::sendEvent( targetObj, &event ); } void Whatever::sendMouseClick( QObject* targetObj, const QPoint& pnt ) const { sendMouseEvent( targetObj, QMouseEvent::MouseMove, pnt ); sendMouseEvent( targetObj, QMouseEvent::MouseButtonPress, pnt ); sendMouseEvent( targetObj, QMouseEvent::MouseButtonRelease, pnt ); } void Whatever::emulateMouseClick( const QPoint& pnt ) const {
Inspired by Using QWebEngine to Render an Image as well as How Can I Draw Events Using QtWebEngine? and googling.
sendevent
source share