Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-68941

Allow PinchHandler to maintain its transformation state when it has no target

XMLWordPrintable

    • b4d31c9ff5f0c5821ea127c663532d9fc2cae43e

      I'm experimenting with PinchHandler in order to make a canvas zoomable using pinch gestures. The canvas has its own zoomLevel property, so it doesn't make sense to modify its scale property. For that reason, I set the handler's target to null. The problem I encountered with this is that each pinch starts from the default scale (1), rather than persisting across pinches. A simple workaround for this is to use an empty Item:

      PinchHandler {
          target: pinchStateItem
      }
      
      // ...
      
      Item {
          id: pinchStateItem
          onScaleChanged: if (canvas) canvas.currentPane.setZoomLevel(scale)
      }
      

      I think it would be useful if PinchHandler maintained its transformation state when it has no target. I can't think of a scenario where you'd want to discard the state between pinches, but if there are valid use cases for that, a property would work too:

      PinchHandler {
          target: null
          maintainState: true
          // persistent: true
          // persistentState: true
          // persistState: true
      }
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            srutledg Shawn Rutledge
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: