Example on faking tap gesture on a desktop app
-
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
-
@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);
}@