简体   繁体   English

Qt 5.5 WebEngineView和多点触控

[英]Qt 5.5 WebEngineView and multitouch

Goal: Responsive multitouch rectangle with WebEngineView inside. 目标:内置WebEngineView的响应式多点触控矩形。

I'm making multitouch web browser. 我正在制作多点触控网页浏览器。 For now I made browser in rectangle with multitouch area over it that coresponds to some mutitouch actions with rectangle resizing, and on short tap sends javascript with click event through runJavaScript function to webpage. 现在我用矩形浏览器设置了多点触控区域,它与矩形调整大小的一些mutitouch操作相对应,并且在短线上通过runJavaScript函数将点击事件发送到网页。 But it has problem for example with google forms thats rejects js inputs. 但它有问题,例如google表单拒绝js输入。 So i try to build click simulation in qt. 所以我尝试在qt中构建点击模拟。

Code of simulator. 模拟器代码。

QMouseEvent * event1 = new QMouseEvent (QEvent::MouseButtonPress, QPoint(x,y),
    Qt::MiddleButton,
    Qt::MiddleButton,
    Qt::NoModifier   );

bool resp1  = QCoreApplication::sendEvent(mainWindow,event1);

QMouseEvent * event2 = new QMouseEvent (QEvent::MouseButtonRelease, QPoint(x,y),
    Qt::MiddleButton,
    Qt::MiddleButton,
    Qt::NoModifier   );

bool resp2  = QCoreApplication::sendEvent(mainWindow,event2);

It works on some cases but not all of them. 它适用于某些情况,但不适用于所有情况。 The problem is that mainWindow is the ApplicationWindow, so x are x of browser rectangle + x of touch in rectangle, and similar with y. 问题是mainWindow是ApplicationWindow,因此x是浏览器矩形的x +矩形触摸的x,与y类似。

Im using MiddleButton in this click simulation, and this is the problem. 我在这个点击模拟中使用了MiddleButton,这就是问题所在。 Not every web button receives midle button click as submit click. 并非每个Web按钮都会在提交单击时收到midle按钮单击。 So i need to pass LEFT button click directly to webengineview. 所以我需要通过LEFT按钮直接点击webengineview。 But when i do this application crashes, because multitoucharea receives it first as touch and sends one again to click simulation. 但是,当我这样做时,应用程序崩溃,因为multitoucharea首先接收它作为触摸并再次发送一个单击模拟。 It creates infinity loop. 它创建了无限循环。

The question is: How to send simulated LEFT click directly to WebEngineView? 问题是:如何将模拟LEFT点击直接发送到WebEngineView?

Ok... I found answer. 好的......我找到了答案。 MultiPointTouchArea has property mouseEnabled. MultiPointTouchArea具有属性mouseEnabled。 When is false, then mouse events are ignored by touch component. 如果为false,则触摸组件将忽略鼠标事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM