I tried to accept touch events in Qt6 like this, in main.cpp:
QApplication::setAttribute(Qt::ApplicationAttribute::WA_AcceptTouchEvents); error: no member named 'WA_AcceptTouchEvents' in 'Qt::ApplicationAttribute'
IntelliSense shows that Qt::ApplicationAttribute has WA_AcceptTouchEvents. But I think it is a bug of Qt Creator because there is no WA_AcceptTouchEvents in Qt::ApplicationAttribute:

and I tried to run this code:
QApplication::setAttribute(Qt::WA_AcceptTouchEvents); error: cannot initialize a parameter of type 'Qt::ApplicationAttribute' with an rvalue of type 'Qt::WidgetAttribute'
I tried to accept it in the window constructor but QOpenGLWindow doesn't have the setAttribute method:
error: use of undeclared identifier 'setAttribute'; did you mean 'QInputMethodEvent::Attribute'?
OpenGLWindow::OpenGLWindow() { setTitle("OpenGL ES 2.0, Qt6, C++"); resize(350, 350); setAttribute(Qt::WA_AcceptTouchEvents); } My pro-file:
QT += core gui opengl widgets CONFIG += c++17 # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. # disables all the APIs deprecated before Qt 6.0.0 # DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 SOURCES += \ main.cpp \ opengl_window.cpp HEADERS += \ opengl_window.h # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target Added
musicamante posted the next link and the quote in the comments below:
the documentation (Event Handling), "Unlike widgets, QWindows receive touch events always, there is no need to opt in. When working directly with a QWindow, it is enough to reimplement QWindow::touchEvent()"
But when I run the next code on the real device, touch a screen (it prints counter = 0), holding a finger on the screen, try to touch with another finger and doesn't print the next line like counter = 1. It seams like multi touch is disabled.
void OpenGLWindow::touchEvent(QTouchEvent *event) { switch (event->type()) { case QEvent::TouchBegin: qDebug()
Источник: https://stackoverflow.com/questions/780 ... nts-in-qt6