Qt::TapAndHoldGesture much to fast



  • 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.


  • Moderators



  • Awesome! Thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.