Qt::TapGesture Gesture is not working properly
-
I have created a custom gesture as,
@
Gesture*
CustomTapGestures::create(QObject* pTarget)
{
QGesture *Gesture = new QTapGesture(pTarget);
return Gesture;
}QGestureRecognizer::Result
CustomTapGestures::recognize(QGesture* Gesture, QObject *Object, QEvent *event)
{
QGestureRecognizer::Result result = QGestureRecognizer::Ignore;return result;
}void
CustomTapGestures::reset(QGesture *Gesture)
{
Gesture->setProperty("startPoint", QVariant(QVariant::Invalid));
parent::reset(Gesture);
}@and I am using that in my event class as
@Screen::Screen(Desktop *Dk)
{
QVBoxLayout screenLayout = new QVBoxLayout ;
screenLayout->addWidget(Dk);
setLayout(screenLayout);
QGestureRecognizer CTap = new CustomTapGestures ;
Qt::GestureType CTapId = QGestureRecognizer::registerRecognizer(CTap) ; ;grabGesture(CTapId);
}
bool Screen::event(QEvent event)
{
event->accept();
if (event->type() == QEvent::Gesture)
return gestureEvent(static_cast<QGestureEvent>(event));
return QWidget::event(event);
}bool Screen::gestureEvent(QGestureEvent *event)
{
if (QGesture *tap = event->gesture(Qt::TapGesture))
ontapTriggered(static_cast<QTapGesture *>(tap));
return true;
}void Screen::ontapTriggered(QTapGesture *gesture)
{
if( gesture->state() == Qt::GestureFinished )
qDebug() << "working QTapGesture" ;
}
@
Here Desktop *Dk is a normal widget having size 1280x640, and when tap on screen it is giving output as working tapgesture even if in my tap recognize am disabled it whatever be the event.. ( i am testing this because for a certain condition I want to disable the tap) please give me a solution Thanks in advace