Hi,
I'm handling TapAndHoldGesture in my Qt Application (version 4.7.4), the gesture is correctly fired and I handle it in the following way:
bool RecipeList
::event(QEvent *event
) {
if (event
->type
() == QEvent::Gesture) { return gestureEvent(static_cast<QGestureEvent*>(event));
}
}
bool RecipeList::gestureEvent(QGestureEvent *event)
{
if (QGesture *swipe = event->gesture(Qt::SwipeGesture))
swipeTriggered(static_cast<QSwipeGesture*>(swipe));
else if (QGesture *tapAndHold = event->gesture(Qt::TapAndHoldGesture))
tapAndHoldTriggered(static_cast<QTapAndHoldGesture*>(tapAndHold));
return true;
}
void RecipeList::tapAndHoldTriggered(QTapAndHoldGesture* tapAndHold)
{
if (tapAndHold->state() == Qt::GestureFinished) {
QLOG_DEBUG() << Q_FUNC_INFO;
}
}
bool RecipeList::event(QEvent *event)
{
if (event->type() == QEvent::Gesture) {
return gestureEvent(static_cast<QGestureEvent*>(event));
}
return QWidget::event(event);
}
bool RecipeList::gestureEvent(QGestureEvent *event)
{
if (QGesture *swipe = event->gesture(Qt::SwipeGesture))
swipeTriggered(static_cast<QSwipeGesture*>(swipe));
else if (QGesture *tapAndHold = event->gesture(Qt::TapAndHoldGesture))
tapAndHoldTriggered(static_cast<QTapAndHoldGesture*>(tapAndHold));
return true;
}
void RecipeList::tapAndHoldTriggered(QTapAndHoldGesture* tapAndHold)
{
if (tapAndHold->state() == Qt::GestureFinished) {
QLOG_DEBUG() << Q_FUNC_INFO;
}
}
To copy to clipboard, switch view to plain text mode
I need to extract the event sender object name, I tried sender()->objectName() but it fails.
How can I make it work?
Thanks
Giovanni
Bookmarks