Example on faking tap gesture on a desktop app
-
wrote on 20 Aug 2010, 10:29 last edited by
Just yesterday a team mate asked me how to fake a gesture event on a desktop, say by clicking on a button, and I quickly wrote "this":http://developer.qt.nokia.com/wiki/TapGestureExampleOnDesktop example using Qt Designer form, a push button when clicked sends a tap gesture
-
wrote on 21 Sept 2010, 16:04 last edited by
@void MainWindow::gest()
{
QTapGesture tapGes;
tapGes.setPosition(QPointF(5,5));
QList<QGesture *> tapGesTureList;
tapGesTureList.append(&tapGes);
QGestureEvent event(tapGesTureList);
QCoreApplication::sendEvent(this, &event);
}@Are you sure that pointer on the tapGes will be alive? May be next better:
@void MainWindow::gest()
{
QTapGesture *tapGes = new QTapGesture(this);
tapGes->setPosition(QPointF(5,5));
QList<QGesture *> tapGesTureList;
tapGesTureList.append(tapGes);
QGestureEvent event(tapGesTureList);
QCoreApplication::sendEvent(this, &event);
}@ -
wrote on 21 Sept 2010, 20:02 last edited by
that example was just to show how to mimic a gesture, and also agree with you that, if required, using a pointer there will keep it alive :)
-
wrote on 22 Sept 2010, 10:27 last edited by
chetankjain, yes:) but, unfortunately, I understood, ~QGestureEvent does not delete pointers on QTapGesture and they all will be accumulated in the application memory and will be deleted only when MainWindow is destroyed.