Apparently, in Chromium and hence QtWebEngine, a long press on a touch screen is translated to a right click (a long mouse-click works fine).
So I want to (try to) capture the touch events in a MouseArea and send them as mouse-click events to WebEngineView (other suggestions are welcomed!)
My QML looks like
WebEngineView {
id: webId
anchors.fill: parent
url: "https://www.qt.io"
}
MouseArea {
anchors.fill: parent
onClicked: clickSimulator.emulateMouseClick(webId, mouse.x, mouse.y)
}
where clickSimulator
is a context property C++ object containing ao.
Q_INVOKABLE void emulateMouseClick(QObject* webView, int mouseX, int mouseY) const;
and in this function, I would like to send QMouseEvent
s to this webView using QCoreApplication::sendEvent
.
However, I can't seem to get this working.
When debugging, the emulateMouseClick
received a QQmlPrivate::QQmlElement<QQuickWebEngineView>`.
I'm not sure how to proceed from here. Suggestions are appreciated.