touchEvent lost
Unsolved
Mobile and Embedded
-
I use "OpenGL Window Example This example shows how to create a minimal QWindow based application for the purpose of using OpenGL"
main//
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(source);QGuiApplication app(argc, argv); QSurfaceFormat format; format.setDepthBufferSize(24); if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { qInfo("Requesting 3.3 core context"); format.setVersion(3, 3); format.setProfile(QSurfaceFormat::CoreProfile); } else { qInfo("Requesting 3.0 context"); format.setVersion(3, 0); } QSurfaceFormat::setDefaultFormat(format); GLWindow gl_window; gl_window.show(); return app.exec();
}
/////
class GLWindow : public QOpenGLWindow
{
Q_OBJECTpublic:
GLWindow();
~GLWindow();void initializeGL() override; void resizeGL(int w, int h) override; void paintGL() override; QByteArray versionedShaderCode(const char *src);
protected:
virtual void touchEvent(QTouchEvent *ev) override;
/////////////////////
void GLWindow::touchEvent(QTouchEvent *e) {switch(e->type()) { case QEvent::TouchBegin: pid.clear(); return ; case QEvent::TouchCancel: pid.clear(); points = e->touchPoints(); update_by_touch(); case QEvent::TouchUpdate: { points.clear(); points = e->touchPoints(); update_by_touch(); } return ;
//////////
device: Android 9;I lost the QEvent::TouchUpdate 5% of all update;
我的英文水平不好,可能表达有错。
我在使用QEvent::TouchUpdate 更新用户交互操作的时候,大约有5%数量的手指滑动事件没有触发,主要在两个手指以上操作的时候,当我的手指从2根变换为1根,事件没有触发,我得到的是2根手指的touchPoints();有时等待1-2秒以后才会得到QEvent::TouchUpdate:是否有一些设置被我忘了?我用多个设备测试,并不是所有设备都有这种情况..