Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. PinchArea
Forum Update on Monday, May 27th 2025

PinchArea

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 2.9k 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.
  • Q Offline
    Q Offline
    qtnext
    wrote on last edited by
    #1

    I am trying to use PinchArea (Qt Quick 1.1) : I have the following :

    @
    import QtQuick 1.1

    Rectangle {
    width: 300
    height: 200
    color:"blue"
    id :mainMT

    PinchArea {
        property int xpoint
        property int ypoint
        property int pinchscale
        property int pinchrotation
    
    
        id: pinchy
        enabled: true
        anchors.fill: parent
        pinch.dragAxis: Pinch.XandYAxis
        pinch.minimumScale: 0.01
        pinch.maximumScale: 20
        onPinchUpdated:
        {
            mainMT.x+=-mapToItem(mainMT.parent,pinch.previousCenter.x,pinch.previousCenter.y).x+mapToItem(mainMT.parent,pinch.center.x,pinch.center.y).x;
            mainMT.y+=-mapToItem(mainMT.parent,pinch.previousCenter.x,pinch.previousCenter.y).y+mapToItem(mainMT.parent,pinch.center.x,pinch.center.y).y;
            mainMT.scale-=pinch.previousScale-pinch.scale;
            mainMT.rotation+=pinch.previousAngle-pinch.angle;
         }
    }
    

    }

    @

    It works well except than it's difficult to move the item with two fingers : when you do that, there is rotation that comes with ...
    Is there a way to enable single touch to move item instead of double touch to distinct move object, and scale/rotation ?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      A couple things you could try:

      • filtering the data in onPinchUpdated (e.g. only change the rotation when the difference in angle passes a certain threshold)
      • use a MouseArea for the single finger dragging (from memory MouseArea and PinchArea should work well together)
      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