#include #include #include #include #include #include #include class MyNativeEventFilter: public QAbstractNativeEventFilter { public: virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE { MSG* msg = (MSG*)(message); int xPos, yPos; switch (msg->message) { case WM_TOUCH: { UINT cInputs = LOWORD(msg->wParam); PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs]; GetTouchInputInfo((HTOUCHINPUT)msg->lParam, cInputs, pInputs, sizeof(TOUCHINPUT)); PTOUCHINPUT firstPoint = &pInputs[0]; int xPos, yPos; xPos = (firstPoint->x) / 100; yPos = (firstPoint->y) / 100; QPoint p(xPos, yPos); m_points.append(p); if (firstPoint->dwFlags & TOUCHEVENTF_UP) { qDebug() << m_points.count(); qDebug() << m_points; m_points.clear(); } } } return false; } QVector m_points; }; int main(int argc, char *argv[]) { QGuiApplication a(argc, argv); QGuiApplication::instance()->installNativeEventFilter(new MyNativeEventFilter()); auto args = QGuiApplication::arguments(); if (args.count() == 1) { QWindow w; w.setTitle("Widget example"); w.showMaximized(); return a.exec(); } else { QQmlEngine engine; QQmlComponent *component = new QQmlComponent(&engine); QObject::connect(&engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); component->setData("import QtQuick 2.10 \n" "import QtQuick.Window 2.10 \n" "Window { \n" " visible: true \n" " title: qsTr(\"Hello World\") \n" "}", QUrl()) ; if (!component->isReady() ) { qWarning("%s", qPrintable(component->errorString())); return -1; } QObject *topLevel = component->create(); QQuickWindow *window = qobject_cast(topLevel); window->setTitle("QML example"); window->showMaximized(); return a.exec(); } }