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. Only receiving Tap and TapAndHold gestures in QGraphicsObject

Only receiving Tap and TapAndHold gestures in QGraphicsObject

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

    I am trying to implement paging in a QGraphicsObject using the swipe gesture.
    First I enable gestures in my QGraphicsObject-derived class:

    grabGesture(Qt::SwipeGesture);
    enableGestureForViews(scene(),Qt::SwipeGesture);
    

    EnableGesturesForViews iterates through all views and enables the gesture for each:

    MyClass::enableGesturesForViews(QGraphicsScene* const pScene, const Qt::GestureType eGesture)
    {
        const auto& views = pScene->views();
        for(auto* const pView : views)
            {
                enableGestureRecursive(pView, eGesture);
            }
    }
    
    MyClass::enableGestureRecursive(QWidget* const pWidget, const Qt::GestureType eGesture)
    {
        if (pWidget == nullptr)
        {
            return;
        }
        pWidget->grabGesture(eGesture);
        pWidget->setAttribute(Qt::WA_AcceptTouchEvents);
        enableGestureRecursive(pWidget->parentWidget(),eGesture);
    }
    

    As you can see, I take no chances. Since the docs isn't very specific where to enable what, I go up all the way to my top-level widget and enable both the gesture and touch.

    In my sceneEvent, I expect the QGestureEvent to arrive:

        if (event->type() == QEvent::Gesture)
        {
            if (handleGestureEvent(event))
            {
                return true;
            }
        }
    

    The content of handleGestureEvent is irrelevant so far, as I never get there. No single gesture is recognized.

    When I enabled all gestures for testing, I did receive Tap and TapAndHold gestures, but neither Pan, Pinch nor Swipe.

    What am I doing wrong?

    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