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 Mac OSX TrackPad finger Capture Operation zoom Solved. :-)
Forum Update on Monday, May 27th 2025

QNativeGestureEvent Mac OSX TrackPad finger Capture Operation zoom Solved. :-)

Scheduled Pinned Locked Moved Solved General and Desktop
macosxqnativegestureezoomtrackpad
2 Posts 2 Posters 980 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.
  • P Offline
    P Offline
    patrik08
    wrote on 12 Aug 2017, 10:40 last edited by
    #1

    At top from my QWidget QAbstractScrollArea i put grabGesture ...

    this->grabGesture(Qt::SwipeGesture,Qt::DontStartGestureOnChildren);
    this->grabMouse();
    this->setContentsMargins(0,0,0,0);
    this->setAcceptDrops(true);
    

    after from main event( QEvent * e) i ast all QNativeGestureEvent
    #include <QInputEvent>
    #include <QNativeGestureEvent>

    & QNativeGestureEvent give value() of the swiped distance and more info about pos on screen
    From the inomming event that i see .. its possibel to rotate paint QWidget...

    ///  mac  trackpad https://support.apple.com/en-us/HT204895
    bool DrawDoument::gestureNative( QNativeGestureEvent * e ) {
       QTextStream  xcout(stdout, QIODevice::WriteOnly);
       QString dir;
         if ( e->value() < 0) {
             distanceswip = distanceswip - e->value();
             setZoom( scaleFaktor - TRACKPADSTEEPS );  /// SCALING_STEEP = 0.075555555
            dir = "zoom in";
          } else {
             distanceswip = distanceswip + e->value();
             setZoom( scaleFaktor + TRACKPADSTEEPS );
             dir = "zoom out";
           }
      xcout << "-----------------swip (" << e->value()  << ")" <<  dir << "x" << POINT_TO_MM(distanceswip) <<"\r";
      e->accept();
      return true;
    }
    bool DrawDoument::event( QEvent * e) {
      if ( e->type() == QEvent::NativeGesture ) {
         return gestureNative(static_cast<QNativeGestureEvent*>(e));
      }
      strak = strak + 0.11; /// visual sleep?
      const int xmac = e->type();
      QTextStream  xcout(stdout, QIODevice::WriteOnly);
      xcout << "E," <<strak << ":->" <<  __FUNCTION__ << " - " << xmac <<"\r";
      return QAbstractScrollArea::event(e);
    }
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 12 Aug 2017, 22:24 last edited by
      #2

      Thanks for sharing your findings !

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      2/2

      12 Aug 2017, 22:24

      • Login

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