Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt::TapAndHoldGesture much to fast
Forum Updated to NodeBB v4.3 + New Features

Qt::TapAndHoldGesture much to fast

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 576 Views 1 Watching
  • 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.
  • P Offline
    P Offline
    peter-70
    wrote on last edited by peter-70
    #1

    I have a piece of code to catch long taps in iOS

    contructor
    {
        this->grabGesture(Qt::TapAndHoldGesture);
    }
    
    bool MediaItem::event(QEvent* e)
    {
        auto event = e->type();
        if (event == QEvent::Gesture)
        {
            auto gesture = dynamic_cast<QGestureEvent*>(e);
            if (gesture)
            {
                return this->HandleGesture(gesture);
            }
        }
    
        return QWidget::event(e);
    }
    
    bool MediaItem::HandleGesture(QGestureEvent* event)
    {
        if (auto gesture = event->gesture(Qt::TapAndHoldGesture))
        {
            auto t = dynamic_cast<QTapAndHoldGesture*>(gesture);
            if (t && t->state() == Qt::GestureStarted)
            {
                emit TapAndHoldStarted();
            }
            else if (t && t->state() == Qt::GestureFinished)
            {
                emit TapAndHoldFinished();
            }
        }
    
        return false;
    }
    

    My signal TapAndHoldFinished is fired after a simple click or tap on the device-display. But I want to wait, and see if it was a long tap or not.

    How can I change the time duration between start and finish of the events?
    Or something else, to see if it was a long tap.

    raven-worxR 1 Reply Last reply
    0
    • P peter-70

      I have a piece of code to catch long taps in iOS

      contructor
      {
          this->grabGesture(Qt::TapAndHoldGesture);
      }
      
      bool MediaItem::event(QEvent* e)
      {
          auto event = e->type();
          if (event == QEvent::Gesture)
          {
              auto gesture = dynamic_cast<QGestureEvent*>(e);
              if (gesture)
              {
                  return this->HandleGesture(gesture);
              }
          }
      
          return QWidget::event(e);
      }
      
      bool MediaItem::HandleGesture(QGestureEvent* event)
      {
          if (auto gesture = event->gesture(Qt::TapAndHoldGesture))
          {
              auto t = dynamic_cast<QTapAndHoldGesture*>(gesture);
              if (t && t->state() == Qt::GestureStarted)
              {
                  emit TapAndHoldStarted();
              }
              else if (t && t->state() == Qt::GestureFinished)
              {
                  emit TapAndHoldFinished();
              }
          }
      
          return false;
      }
      

      My signal TapAndHoldFinished is fired after a simple click or tap on the device-display. But I want to wait, and see if it was a long tap or not.

      How can I change the time duration between start and finish of the events?
      Or something else, to see if it was a long tap.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @peter-70
      QTabAndHoldGesture::setTimeout()

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      P 1 Reply Last reply
      2
      • raven-worxR raven-worx

        @peter-70
        QTabAndHoldGesture::setTimeout()

        P Offline
        P Offline
        peter-70
        wrote on last edited by
        #3

        Awesome! Thanks!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved