Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. macOS Trackpad Gestures - Simultaneous Pinch & Pan?
Forum Updated to NodeBB v4.3 + New Features

macOS Trackpad Gestures - Simultaneous Pinch & Pan?

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 87 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.
  • M Offline
    M Offline
    mjiggidyj
    wrote last edited by aha_1980
    #1

    On macOS with multitouch trackpad (so: traditional macOS desktop app utilizing Macbook trackpad, Magic Mouse, etc), I would like to handle two gestures simultaneously:

    • User pinching to zoom in/out
    • User moving hand (while pinching) to pan around

    So, simultaneously I want my object to scale as the user pinches in/out AND follow the center point of that pinch around the screen to move it while it scales.

    I find the best luck getting pinch-to-zoom data from QNativeGestureEvent:

    	if event.type() == QtCore.QEvent.Type.NativeGesture and \
    	  event.gestureType() == QtCore.Qt.NativeGestureType.ZoomNativeGesture:
    		print("Zoom delta:", event.value())
    

    And I can get two-finger pan gesture info from QWheelEvent:

    	if event.type() == QtCore.QEvent.Type.Wheel:
    		print("Wheel delta:", event.angleDelta())
    

    However, if the user is zooming, I do not get QWheelEvents reported. And if the user is panning, I do not get the native gestures reported.

    Furthermore, any positional info I get from the QNativeGestureEvent during pinch (from pos(), etc) is not updated -- it just reports the centerpoint as it was when the pinch was initiated, but does not move "live." Experimented with setMouseTracking(True) on the widget but that didn't update center points live.

    jsulmJ 1 Reply Last reply
    0
    • M mjiggidyj

      On macOS with multitouch trackpad (so: traditional macOS desktop app utilizing Macbook trackpad, Magic Mouse, etc), I would like to handle two gestures simultaneously:

      • User pinching to zoom in/out
      • User moving hand (while pinching) to pan around

      So, simultaneously I want my object to scale as the user pinches in/out AND follow the center point of that pinch around the screen to move it while it scales.

      I find the best luck getting pinch-to-zoom data from QNativeGestureEvent:

      	if event.type() == QtCore.QEvent.Type.NativeGesture and \
      	  event.gestureType() == QtCore.Qt.NativeGestureType.ZoomNativeGesture:
      		print("Zoom delta:", event.value())
      

      And I can get two-finger pan gesture info from QWheelEvent:

      	if event.type() == QtCore.QEvent.Type.Wheel:
      		print("Wheel delta:", event.angleDelta())
      

      However, if the user is zooming, I do not get QWheelEvents reported. And if the user is panning, I do not get the native gestures reported.

      Furthermore, any positional info I get from the QNativeGestureEvent during pinch (from pos(), etc) is not updated -- it just reports the centerpoint as it was when the pinch was initiated, but does not move "live." Experimented with setMouseTracking(True) on the widget but that didn't update center points live.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote last edited by
      #2

      @mjiggidyj said in macOS Trackpad Gestures - Simulatneous Pinch & Pan?:

      any positional info I get from the QNativeGestureEvent during pinch (from pos(), etc) is not updated

      What about https://doc.qt.io/qt-6/qnativegestureevent.html#delta ?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      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