Multitouch in Linux
-
19-09-2019 - |
Question
I have two questions:
- How to simulate touch event in linux.
- How to work with multitouch on Qt in Linux.
Solution
You can simulate touch events by calling qt_translateRawTouchEvent
directly. (This method is not documented, but it's in qapplication.cpp
and it's exported).
You want to put this at the top of your file:
// forward-declaration of Qt internal function
Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window,
QTouchEvent::DeviceType deviceType,
const QList<QTouchEvent::TouchPoint> &touchPoints);
The function call syntax is :
qt_translateRawTouchEvent(targetWidget, deviceType, points.values());
In your case call this method with (NULL, QTouchEvent::TouchScreen, touchPoints)
where touchPoints
is your list of points being currently touched by the user.
This should work in Qt 4.7 and 4.8 at least, possibly before in Qt 5 but I didn't check that.
OTHER TIPS
For the multitouch question, you are probably wanting to have a look at the Gestures API that Qt has added.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow