Qt 5.12 Unable To Get Touch Events
-
I am working on very complicated Qt project. I have a GL screen on my app and I want it to be zoomed in/out with touch screen moves. But unfortunetly I can't handle touch events.
I added a line to accept touch events to my constructor.
setAttribute(Qt::WA_AcceptTouchEvents, true);
And here is my event function under protected that I print events that happened.
class MyWidget: public QGLWidget { Q_OBJECT protected: bool event(QEvent *event) override { // Print the event type qDebug() << "Event Type: " << event->type(); if (event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate || event->type() == QEvent::TouchEnd) { QTouchEvent *touchEvent = static_cast<QTouchEvent*>(event); QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints(); if (touchPoints.count() == 2) { QTouchEvent::TouchPoint touchPoint1 = touchPoints.at(0); QTouchEvent::TouchPoint touchPoint2 = touchPoints.at(1); qDebug() << "Touch 1: " << touchPoint1.pos(); qDebug() << "Touch 2: " << touchPoint2.pos(); } return true; } return QWidget::event(event); }
And I added this line to my main function:
app.setAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents);
When I try to touch from touch screen, what printed in output is QEvent::MouseButtonPress.
So anyone know what to do, I would be grateful.
-
@duhanayan said in Qt 5.12 Unable To Get Touch Events:
AA_SynthesizeTouchForUnhandledMouseEvents
That is a known bug, unfortunately.
It won´t be fixed in 5.12, but everything works in Qt 6. -
@Axel-Spoerl So you can close the bug :)
-
@Christian-Ehrlicher
Done, Sir :-)
I was just not sure, whether the fix happened in 5.15 or 6.2.
The latter it is.