How to Create a QTapAndHoldGesture & Swipe Gesture in Qt?
I am new to this qt- forum. This is My First Post. Happy to write here :-)
Can anyone please post a simple working example for QTapAndHold Gesture and Swipe Gesture? I got very few examples from internet and tried with that.. None was working correct..
Welcome to Qt Forum! Hope this helps you to grab the Tap and Hold Gesture...
MainWindow::MainWindow(QWidget *parent) :
bool MainWindow::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));
qDebug() << "Gesture position is : " << tapgest->position();
what do you have so far? what have you tried?
Did you use QWidget::grabGesture()?
Thanks for your replies.
I have a another question regarding the same topic. Is it possible to grab a gesture for a Particular Component (say QPushButton).
I have a QPushButton. For that I have to grab the Gesture for it. But the Grab Gesture grabs for the whole widget and not for the particular component.
Please give your suggestions about it.
Is the solution provided by Rochi working for you ??? Actually this solution is not working for me. I am not able to recognize the QTapAndHold Gesture. I am using Qt 4.8 on Windows 7.
Thanks in advance....