Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can't catch TapAndHoldGesture
Forum Updated to NodeBB v4.3 + New Features

Can't catch TapAndHoldGesture

Scheduled Pinned Locked Moved Unsolved General and Desktop
gestureqgestureevent
1 Posts 1 Posters 800 Views
  • 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 Offline
    A Offline
    AlaaM
    wrote on last edited by AlaaM
    #1

    I grabGesture()ed one of my buttons:

    buttons[0]->grabGesture(Qt::TapAndHoldGesture);
    

    in the constructor, and declared:

    bool event(QEvent *event);
    

    in protected slots, and implemented it like this:

    bool MyClass::event(QEvent *event)
    {
        if (event->type() == QEvent::Gesture){
            QGestureEvent *gestevent = static_cast<QGestureEvent *>(event);
            if (QGesture *gest = gestevent->gesture(Qt::TapAndHoldGesture)){
                QTapAndHoldGesture *tapgest = static_cast<QTapAndHoldGesture *>(gestevent->gesture(Qt::TapAndHoldGesture));
                cout << "grabbed a gesture event" << endl;
            }
            return true;
        }
        cout << "not a gesture event" << endl;
        return QWidget::event(event);
    }
    

    and I keep getting "not a gesture event" printed to screen.

    What I'm trying to do is a long key press (from the keyboard)

    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