'Why Touchscreen don't work with WebAssembly?

I'm developing an webassembly application that must use touchscreen. I studied the examples: dials fingerpaint knobs pinchzoom (see https://doc.qt.io/qt-6/touchinputexamples.html)

I tryed to run the tablet example (see https://doc.qt.io/qt-6/qtwidgets-widgets-tablet-example.html) compiled in webassembly but don't work. I have this problem: If I compile my application with MinGW kit (Desktop application), I'm able to move a dialog tapped on title section with my finger, and I can see the debug print that show the events below:

QEvent::WindowActivate
QEvent::NonClientAreaMouseMove
QEvent::NonClientAreaMouseButtonPress
QEvent::NonClientAreaMouseButtonRelease
QEvent::NonClientAreaMouseMove

If I compile my application with WebAssembly kit (WebAssembly application), I'm NOT able to move the dialog tapped on title. these are the event that I can see the event printed on console:

QEvent::MouseMove
QEvent::MouseButtonRelease
QEvent::MouseButtonPress

I tryed to repete the test with the WA_AcceptTouchEvents sets to false, befor and sets to true after. But I had the same behavior.

My question is: how can I perform the same behaviour in both configurations I posted a minimal application affected for same issue The example is composed by a MainWindow that show a non modal dialog, across the menu file, open. The dialog is a simple default QDialog with two button (ok and cancel) My configuration:

Qt Creator 7.0.0 Based on Qt 6.2.3 (MSVC 2019, 64 bit) From revision 638b93591b

Qt 6.3.0 WebAssembly with Emscripten 3.1.6 for C++

Google Chrome Ver. 101.0.4951.54

// here the WasmDialog.pro file 

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

SOURCES += \
    ExtGraphicsWidget.cpp \
    WasmDialog.cpp \
    main.cpp \
    MainWindow.cpp

HEADERS += \
    ExtGraphicsWidget.h \
    MainWindow.h \
    WasmDialog.h

FORMS += \
    mainwindow.ui \
    wasmdialog.ui

qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target


// here main.cpp code:

#include "MainWindow.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}

// here the MainWindow.h file 

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "WasmDialog.h"

QT_BEGIN_NAMESPACE
namespace Ui { 
    class MainWindow; 
}

QT_END_NAMESPACE

class QGraphicsView;
class QGraphicsScene;
class ExtGraphicsWidget;

class MainWindow : public QMainWindow
{
    Q_OBJECT

    public:
        MainWindow(QWidget *parent = nullptr);
        ~MainWindow();

    private:
        Ui::MainWindow *ui;
        WasmDialog moWD;
        QGraphicsView *mpView;
        QGraphicsScene *mpScene;
};
#endif // MAINWINDOW_H

// here the MainWindow.cpp file 

#include "MainWindow.h"
#include "ui_mainwindow.h"

#include <ExtGraphicsWidget.h>

#include <QGraphicsView>
#include <QGraphicsAnchorLayout>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
    , mpView(nullptr)
    , mpScene(nullptr)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_AcceptTouchEvents, false);

    connect(ui->actionOpen, &QAction::triggered, &moWD, &WasmDialog::show);

    mpScene = new QGraphicsScene(this);
    mpView = new QGraphicsView(this);
    mpView->setScene(mpScene);
    setCentralWidget(mpView);
} // ctr

MainWindow::~MainWindow()
{
    if (nullptr != mpScene)
    {
        delete mpScene;
    } // end if nullptr != mpScene)

    if (nullptr != mpView)
    {
        delete mpView;
    } // end if nullptr != mpView)

    delete ui;
} // dtr

// here the WasmDialog.h file 

#ifndef WASMDIALOG_H
#define WASMDIALOG_H

#include <QDialog>

namespace Ui 
{
    class WasmDialog;
}

class WasmDialog : public QDialog
{
    Q_OBJECT

    public:
        explicit WasmDialog(QWidget *parent = nullptr);
        ~WasmDialog();

    protected:
        bool event(QEvent *event) override;
        void tabletEvent(QTabletEvent *event) override;

    private:
        Ui::WasmDialog *ui;
};

#endif // WASMDIALOG_H

// here the WasmDialog.cpp file 

#include "WasmDialog.h"
#include "ui_wasmdialog.h"

#include <QDebug>
#include <QMoveEvent>

WasmDialog::WasmDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::WasmDialog)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_AcceptTouchEvents, false);
    setWindowFlags(windowFlags() | Qt::WindowTitleHint);

} // ctr

WasmDialog::~WasmDialog()
{
    delete ui;
} // dtr

bool WasmDialog::event(QEvent *event)
{
    qDebug() << " e->type " <<  event->type();
    return QDialog::event(event);
}

void WasmDialog::tabletEvent(QTabletEvent *event)
{
    switch (event->type())
    {
        case QEvent::TabletPress:
        case QEvent::TabletMove:
        {
            qDebug() << " e->type " <<  event->type();
            break;
        }
        case QEvent::TabletRelease:
        {
            qDebug() << " e->type " <<  event->type();
            update();
            break;
        }
        default:
        {
            break;
        }
    }
    QDialog::tabletEvent(event);
}


Solution 1:[1]

this is a bug discovered on WebAssemblu 6.3.0: https://bugreports.qt.io/browse/QTBUG-103498

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Drow