QTouchEvent error
-
Our software is working in the surface go3 with ubuntu20.0.4;
Here is a strange error happening when do touch event.
When user is touching on our software(show on the surface with the whole screen), and at the same time, click the power button of surface and show the close dialog. when we click the cancel btn, the screen will still display our software, while our touch operation might be uneffected. The touch event can be normal if we remove the Docking Station.In order to Troubleshoot this problem, we write a very simple project, which contains a QMainWindow and QPushbutton. when we touch the mainwindow, and trigger a new dialog from other exe at the same time, the touchevent of this simple project also don't work normally.
-
@jiangxinyi1029 Not very clear about your issue. But you can add eventFilter in the mainwindow of your simple project to test if the touch event arrives. Qt does have issues on touch screen and sometimes it does not update widgets properly. However, I have not seen any problem with qml.
-
@JoeCFD
In order to troubleshoot this problem, we write a very simple project(testDemo), which only contains a QMainWindow. when we touch the mainwindow, and trigger a new dialog from other exe at the same time, the touchevent of this simple project also don't work normally.bool MainWindow::event(QEvent *event) { switch (event->type()) { case QEvent::MouseButtonPress: { QMouseEvent* mouse = (QMouseEvent*)event; gPos = mouse->localPos(); qDebug() << "[mousePress]" << (Qt::MouseEventSource)mouse->source() << (Qt::MouseButton)mouse->button() << gPos.rx() << gPos.ry() << event->spontaneous(); QMainWindow::mousePressEvent(mouse); break; } case QEvent::MouseButtonRelease: { QMouseEvent* mouse = (QMouseEvent*)event; gPos = mouse->localPos(); qDebug() << "[MouseRelease]" << (Qt::MouseEventSource)mouse->source() << (Qt::MouseButton)mouse->button() << gPos.rx() << gPos.ry() << event->spontaneous(); QMainWindow::mouseReleaseEvent(mouse); break; } case QEvent::MouseMove: { QMouseEvent* mouse = (QMouseEvent*)event; gPos = mouse->localPos(); qDebug() << "[MouseMove]" << (Qt::MouseEventSource)mouse->source() << (Qt::MouseButton)mouse->button() << gPos.rx() << gPos.ry() << event->spontaneous() << cnt2++; QMainWindow::mouseMoveEvent(mouse); break; } case QEvent::TouchBegin: { QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); qDebug() << "[TouchBegin] : " << (Qt::TouchPointStates)touchEvent->touchPointStates() // << (QTouchDevice::DeviceType)touchEvent->device()->type() 0 << cnt++ << touchEvent->touchPoints().count() << (Qt::TouchPointState)touchEvent->touchPoints().at(0).state() << event->spontaneous(); break; // event->ignore(); // return true; } case QEvent::TouchUpdate: { QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); qDebug() << "[TouchUpdate] : " // << (QTouchDevice::DeviceType)touchEvent->device()->type() << cnt++ << (Qt::TouchPointState)touchEvent->touchPoints().at(0).state() << event->spontaneous(); break; // return true; } case QEvent::TouchEnd: { QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); qDebug() << "[TouchEnd] : " // << (QTouchDevice::DeviceType)touchEvent->device()->type() << cnt++ << (Qt::TouchPointState)touchEvent->touchPoints().at(0).state() << event->spontaneous(); break; // return true; } case QEvent::TouchCancel: { QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); qDebug() << "[TouchCancel] : " << (QTouchDevice::DeviceType)touchEvent->device()->type() << cnt++; break; // return true; } case QEvent::FocusIn: { QFocusEvent *fcEvent = static_cast<QFocusEvent *>(event); qDebug() <<"[focus in] : "<< (Qt::FocusReason)fcEvent->reason() ; // QTouchEvent* event = new QTouchEvent(QEvent::ActivationChange); // qApp->postEvent(qApp,event); break; } case QEvent::FocusOut: { QFocusEvent *fcEvent = static_cast<QFocusEvent *>(event); qDebug() <<"[focus out] : " << (Qt::FocusReason)fcEvent->reason() ; break; } default: // if(event->spontaneous()) { // event->accept(); // return true; // } if(event->type() != QEvent::HoverMove && event->type() != QEvent::Move) { qDebug() << (QEvent::Type)event->type() << event->spontaneous(); } break; } return QMainWindow::event(event); }
We have tried to print the event loop during this operation, we found that the first time we touch the testDemo, touchbegin, mousemove can be printed, and mouserelease event can be printed when we release our finger from the testDemo;
When we first touch the testDemo with one finger(finger1), and we trigger a new dialog from other exe(for example, click any tool bar of qtcreator ) with another finger(finger2).
This time we release finger2 first, touch the testDemo again, it can only print the mousemove with the same position of the last mousemove pos, and the touch event can not be worked normally until we unplug the docking station of Surface.
I have found the same question in this link
https://forum.qt.io/topic/135219/qt-widgets-not-responding-to-touch-event-sometimes.
There is still no issue how to solve this problem.Do you have any suggestion on this question?
And thanks for your help~