Hi! I'm trying to enable a swipe gesture. I created a test class like this following the documentation and the example:
GestureLabel
::GestureLabel(QWidget *parent
) :{
grabGesture(Qt::SwipeGesture);
}
bool GestureLabel
::event(QEvent *e
) {
if (e
->type
() == QEvent::Gesture) return gestureEvent(static_cast<QGestureEvent*>(e));
}
bool GestureLabel::gestureEvent(QGestureEvent *event)
{
if (QGesture *swipe = event->gesture(Qt::SwipeGesture))
swipeTriggered(static_cast<QSwipeGesture *>(swipe));
return true;
}
void GestureLabel::swipeTriggered(QSwipeGesture *gesture)
{
QMessageBox::information(this,
"Gesture!",
"Gesture!");
}
GestureLabel::GestureLabel(QWidget *parent) :
QWidget(parent)
{
grabGesture(Qt::SwipeGesture);
}
bool GestureLabel::event(QEvent *e)
{
if (e->type() == QEvent::Gesture)
return gestureEvent(static_cast<QGestureEvent*>(e));
return QWidget::event(e);
}
bool GestureLabel::gestureEvent(QGestureEvent *event)
{
if (QGesture *swipe = event->gesture(Qt::SwipeGesture))
swipeTriggered(static_cast<QSwipeGesture *>(swipe));
return true;
}
void GestureLabel::swipeTriggered(QSwipeGesture *gesture)
{
QMessageBox::information(this, "Gesture!", "Gesture!");
}
To copy to clipboard, switch view to plain text mode
Seems not to recognize swipes. I tried to put a breakpoint in line:
return gestureEvent(static_cast<QGestureEvent*>(e));
return gestureEvent(static_cast<QGestureEvent*>(e));
To copy to clipboard, switch view to plain text mode
and seems the execution doesn't stop there. Is there anything I'm doing wrong? Am I lacking anything?
Thanks for any advice!
Bookmarks