Important: Please read the Qt Code of Conduct -

Missing TouchEvent

  • Hi,
    i need some help regarding touch events.
    I created a QWindow and reimplemented the touchEvent function.
    My problem is when i use more than one finger on the touchpad, i only get 1 TouchEnd notification.


    I implemented a custom QAbstractNativeEventFilter which sends a QTouchEvent to my window which looks like this:

    class TouchEventFilter : public QAbstractNativeEventFilter
        virtual bool nativeEventFilter(const QByteArray &eventType, void* message, long*) Q_DECL_OVERRIDE
            if (eventType == "windows_generic_MSG")
                MSG* msg = static_cast<MSG*>(message);
                if (msg->message == WM_POINTERUP)
                    if ((WId)(msg->hwnd) == window->winId())
                        QList<QTouchEvent::TouchPoint> touchPoints;
                        QTouchEvent::TouchPoint point;
                        QPointF position(GET_X_LPARAM(msg->lParam), GET_Y_LPARAM(msg->lParam));
                        point.setId(?????); // <---
                        QTouchEvent te(QEvent::TouchEnd, nullptr, 0, Qt::TouchPointReleased, touchPoints);
                        QApplication::sendEvent(window, &te);
                        return true;
            return false;
        QWindow* window;

    My problem is that i have to assign the right id to the TouchPoint object, otherwise i cannot distinguish it from the other touch inputs i received in my application.
    Any help would be appreciated.


Log in to reply