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. Methode for incremental Scale (pincharea) of an Image in Qml?
Qt 6.11 is out! See what's new in the release blog

Methode for incremental Scale (pincharea) of an Image in Qml?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 1.2k 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.
  • PowerNowP Offline
    PowerNowP Offline
    PowerNow
    wrote on last edited by PowerNow
    #1

    Hi, I'm just looking for a method to 'incremental' Scale an Image in Qml. This means

    1. start pinch at Center.x/y and e.g. increase Scale -> Scale/Zoom into Image starting from point with Center.x/y
    2. stop pinch
    3. start next pinch at different Center.x/y and continue with Scale -> Image jumps to another point and continues with Scale.

    The reason for the jump is that Scale always starts with Scaling=1 at current Center.x/y. I need Scale because I use a big Frambufferobject and Flickable leads to new calculation and makes everthing very slow.

    import QtQuick 2.6
    Rectangle {
        id: iTImag
        state: "start"
        anchors.fill: parent
        color: "#343434"
    
        Image {
            id: iImage
            width: parent.width
            height: parent.height
            source: Imag.url
            sourceSize.width: width
            fillMode: Image.PreserveAspectFit
    
            transform:
                Scale {
                	id: iScale
                }
        }
    
        PinchArea {
            id: iPinchArea
            anchors.fill: parent
            pinch.minimumScale: 1
            pinch.maximumScale: 8
    
            property real mScale: 1
    
            onPinchStarted: {
                iScale.xScale = mScale;
                iScale.yScale = mScale;
    
            }
            onPinchUpdated: {
                console.log("onPinchUpdated");           
    
                iScale.origin.x = pinch.center.x;
                iScale.origin.y = pinch.center.y;
    
                mScale += pinch.scale - pinch.previousScale;
    
                iScale.xScale = mScale;
                iScale.yScale = mScale;
            }
        }
    }
    
    

    Does maybe anyone has an idea?

    1 Reply Last reply
    0
    • PowerNowP Offline
      PowerNowP Offline
      PowerNow
      wrote on last edited by
      #2

      This helped me really!

      https://stackoverflow.com/questions/24478653/how-to-use-qml-scale-element-for-incremental-scaling-with-different-origin/27376997

      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