Qt 6.11 is out! See what's new in the release
blog
How to handle a release event for the second finger in QOpenGLWindow
-
I'm trying to create an Android game controller to make a Super Mario clone, just to learn programming and practice:

The next problem stopped me. I touch the screen with my first finger. While holding the first finger, I touch and release the second finger. I expect that when I release the second finger, the Qt Creator debug console should display:
TouchUpdate 2 TouchUpdate 1void OpenGLWindow::touchEvent(QTouchEvent *event) { switch (event->type()) { case QEvent::TouchBegin: { qDebug() << "TouchBegin"; event->accept(); break; } case QEvent::TouchUpdate: { qDebug() << "TouchUpdate " << event->points().length(); break; } } }But only the first few releases work normally. Then the releases work with delays. And after a few more releases I see:
TouchUpdate 2 TouchUpdate 2Minimal example: release-event-of-the-second-finger-qt6-cpp.zip
-
Solution: https://doc.qt.io/qt-6/qeventpoint.html#State-enum
void OpenGLWindow::touchEvent(QTouchEvent *event) { switch (event->type()) { case QEvent::TouchBegin: { qDebug() << "TouchBegin"; event->accept(); break; } case QEvent::TouchUpdate: { if (event->points().length() > 1) { QEventPoint::State firstState = event->points()[0].state(); QEventPoint::State secondState = event->points()[1].state(); if (firstState == QEventPoint::State::Released || secondState == QEventPoint::State::Released) { qDebug() << "Released"; } } break; } } } -
8 8Observer8 has marked this topic as solved on