Как принять события касания в Qt6?Android

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Anonymous
 Как принять события касания в Qt6?

Сообщение Anonymous »


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
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Как принять события касания в Qt6?
    Anonymous » » в форуме Android
    0 Ответы
    26 Просмотры
    Последнее сообщение Anonymous
  • Как принять события касания в Qt6?
    Anonymous » » в форуме C++
    0 Ответы
    18 Просмотры
    Последнее сообщение Anonymous
  • Как принять события касания в Qt6? [закрыто]
    Гость » » в форуме C++
    0 Ответы
    25 Просмотры
    Последнее сообщение Гость
  • Как принять события касания в Qt6?
    Гость » » в форуме Android
    0 Ответы
    26 Просмотры
    Последнее сообщение Гость
  • Как принять события касания в Qt6?
    Anonymous » » в форуме C++
    0 Ответы
    25 Просмотры
    Последнее сообщение Anonymous

Вернуться в «Android»