Ich beschäftige mich aktuell mit der Erstellung eines GUIs (bzw. NUIs), welches über Touch bedienbar sein soll.
Dabei will ich meine Logik in C++ und meine GUI/NUI unter QML erstellen. Hierfür möchte ich das Programm mithilfe eigenständig erstellter Touch Events testen. Grundsätzlich würde sich das Modul "QtTest" dafür gut eignen. Allerdings schaffe ich keine Multi-Touch Events zum QML erstelltem Programmteil zu senden. Mausevents, welche als singletouch interpretiert werden, funktionieren hingegen. Kann jemand an dieser Stelle aushelfen?
Mein C++-Quellcode sieht wie folgt aus:
Code: Alles auswählen
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtTest>
#include <QObject>
#include <QWindow>
#include <QDebug>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QObject *obj = qobject_cast<QObject *>(engine.rootObjects().value(0));
QWindow *view = static_cast<QWindow *>(obj);
// emittiere ein touch-press
QTest::touchEvent(view,0, true).press(0,QPoint(10,10),view);
return app.exec();
}
Code: Alles auswählen
import QtQuick 2.5
import QtQuick.Window 2.2
Window
{
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Rectangle
{
width: 400; height: 400
anchors.fill: parent
MultiPointTouchArea
{
anchors.fill: parent
touchPoints: [
TouchPoint { id: point1 },
TouchPoint { id: point2 }
]
onPressed:
{
console.log("pressed")
}
}
}
}