Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt::TapGesture Gesture is not working properly

    General and Desktop
    1
    1
    490
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Akhil. V . S last edited by

      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

      1 Reply Last reply Reply Quote 0
      • First post
        Last post