Reputation: 368
I want to add swipe gestures in my application based on Qt5. The application is intended to run primarily on Linux (laptop). I was just not able to write code because I couldn't understand how to use the class (no example code was available).
The touchpad driver supports swipe gestures (libinput). Also, synaptics (on my system at least) support multi-finger touch.
Can someone please guide me about how to use the API, and provide with some example code?
Upvotes: 0
Views: 396
Reputation: 98465
Do you mean QNativeGestureEvent
? You probably shouldn't mess with QNativeGestureEvent
and use the higher-level framework: see Gestures in Widgets and Graphics View. The QNativeGestureEvent
used to be only available on OS X; it's not really an API that's meant for wide consumption.
Alas, the QNativeGestureEvent
s are delivered to the widgets themselves. You would react to them by reimplementing QObject::event
and acting on the event:
class MyWidget : public QWidget {
typedef base_type = QWidget;
...
bool QWidget::event(QEvent * ev) override {
if (ev->type() == QEvent::NativeGesture) {
auto g = static_Cast<QNativeGestureEvent*>(ev);
...
return true; // if event was recognized and processed
}
return base_type::event(ev);
}
};
But don't do that.
Upvotes: 0