Can't catch TapAndHoldGesture
Unsolved
General and Desktop
-
I
grabGesture()
ed one of my buttons:buttons[0]->grabGesture(Qt::TapAndHoldGesture);
in the constructor, and declared:
bool event(QEvent *event);
in
protected slots
, and implemented it like this:bool MyClass::event(QEvent *event) { if (event->type() == QEvent::Gesture){ QGestureEvent *gestevent = static_cast<QGestureEvent *>(event); if (QGesture *gest = gestevent->gesture(Qt::TapAndHoldGesture)){ QTapAndHoldGesture *tapgest = static_cast<QTapAndHoldGesture *>(gestevent->gesture(Qt::TapAndHoldGesture)); cout << "grabbed a gesture event" << endl; } return true; } cout << "not a gesture event" << endl; return QWidget::event(event); }
and I keep getting "not a gesture event" printed to screen.
What I'm trying to do is a long key press (from the keyboard)