How to listen to QTouchEvent originating from a precision touch pad?
Unsolved
General and Desktop
-
I have a Windows 10 laptop with a precision touchpad. I have been unsuccessfully trying to listen to QTouchEvent's originating from the touchpad. This is my code (Qt 5.9.4_patch2):
#include <QApplication> #include "MyWindow.h" int main(int argc, char **argv) { QApplication app(argc, argv); MyWindow window; window.show(); return app.exec(); } //MyWindow.h #pragma once #include <QtWidgets> class MyWindow : public QWindow { Q_OBJECT public: MyWindow(); protected: void touchEvent(QTouchEvent* e) override; bool event(QEvent* e) override; }; //MyWindows.cpp #include "MyWindow.h" MyWindow::MyWindow() : QWindow() { } void MyWindow::touchEvent(QTouchEvent* e) { qDebug() << "Touch!!"; } bool MyWindow::event(QEvent* e) { qWarning() << e->type(); return QWindow::event(e); }
The touch events never get triggered. I tried this too, but didn't work.
Any ideas?
-
@jsulm QTouchEvent class has the method *QTouchDevice QTouchEvent::device(). The device type QTouchDevice::TouchPad is supported by QT. So If I understand QTouchEvent documentation correctly, it should be possible.
Access to the multitouch data from multi-touch-capable precision touchpads is possible in Windows via a low-level Window's API (e.g. GetRawInputData()). I was guessing/hoping that QTouchEvent was a higher-level, multiplatform solution on top of this.