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. QNativeGestureEvent does not pick up SwipeNativeGesture on Mac OS X?
Forum Updated to NodeBB v4.3 + New Features

QNativeGestureEvent does not pick up SwipeNativeGesture on Mac OS X?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 852 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.
  • R Offline
    R Offline
    rushmore
    wrote on last edited by
    #1

    Hi all,

    I was trying to implement native gesture support for my Mac app. It appears QNativeGestureEvent can only pick up native zoom and rotate gesture, but not swipe gesture on the touch pad. If I print out the event, all I get is a BeginNativeGesture and a EndNativeGesture with value unchanged. Has anyone else successfully implemented native swipe gesture in their code?

    Thank you!

    1 Reply Last reply
    0
    • P Offline
      P Offline
      patrik08
      wrote on last edited by
      #2

      I confirm...
      QAbstractScrollArea->grabGesture(Qt::SwipeGesture, Qt::ReceivePartialGestures);
      only swipe distance is registred... can use 4 zoom not to chance page like ebook reader or so..

      but in qt5 code is here qnsview.mm .. line 1350
      i try to pic up the event on qmainwindow core..

      - (void)swipeWithEvent:(NSEvent *)event
      {
          if (!m_platformWindow)
              return;
      
          qCDebug(lcQpaGestures) << "swipeWithEvent" << [event deltaX] << [event deltaY];
          const NSTimeInterval timestamp = [event timestamp];
          QPointF windowPoint;
          QPointF screenPoint;
          [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
      
          qreal angle = 0.0f;
          if ([event deltaX] == 1)
              angle = 180.0f;
          else if ([event deltaX] == -1)
              angle = 0.0f;
          else if ([event deltaY] == 1)
              angle = 90.0f;
          else if ([event deltaY] == -1)
              angle = 270.0f;
      
          QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::SwipeNativeGesture,
                                                                  angle, windowPoint, screenPoint);
      }
      

      Waht is work is this: (no axis)

      ///  mac  trackpad https://support.apple.com/en-us/HT204895
      bool DrawDocument::gestureNative(QNativeGestureEvent *e) {
        if (e->type() == QEvent::NativeGesture) {
          if (e->value() < 0) {
            distanceswip = distanceswip - e->value();
            setZoom(scaleFaktor - TRACKPADSTEEPS);
          } else {
            distanceswip = distanceswip + e->value();
            setZoom(scaleFaktor + TRACKPADSTEEPS);
          }
        }
        return true;
      }
      
      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