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. pinch/scroll zoom like google map
Forum Updated to NodeBB v4.3 + New Features

pinch/scroll zoom like google map

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 425 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.
  • Y Offline
    Y Offline
    ynatynat
    wrote on last edited by
    #1

    I would like to zoom image like google maps.
    With Google Maps, the location user want to enlarge (the location where the cursor is placed) is always displayed at the same position and zoomed.
    How to do?

                        Rectangle{
                            id:image_wrapper
                            width:parent.width*0.8
                            height:parent.height
                            anchors.left: btn_back.right
    
                            color:"cyan"
                            border.color:"blue"
                            clip:true
                            Image {
                                id: image
                                anchors.centerIn: parent
                                fillMode: Image.PreserveAspectFit
                                source: contextLoadImages.imageSource
                                antialiasing: true
                            }
                        }
    
    
                        Flickable{
                            id:flick2
                            anchors.fill:image_wrapper
    
                            PinchArea{
                                anchors.fill: parent
                                pinch.target: image
                                pinch.minimumScale: 0.1
                                pinch.maximumScale: 10
                                pinch.dragAxis: Pinch.XAndYAxis
                                onPinchStarted:{
                                     // not called
                                }
                                onSmartZoom: {
                                    // not called
    
                                }
                                MouseArea{
                                    id:mousearea
                                    anchors.fill: parent
                                    drag.target: image
                                    drag.axis: Drag.XAndYAxis
                                    hoverEnabled: true
                                    scrollGestureEnabled: false// 2-finger-flick gesture should pass through to the Flickable (@ Example:photo surface)
                                    onPressed:{
                                        image.anchors.centerIn=undefined
                                        
                                    }
                                    onPositionChanged: {
                                        //console.log("xy=",mouse.x, mouse.y  )
                                        //let pos = mapToItem(image, mouse.x, mouse.y)
    
                                    }
    
                                    onWheel: {
                                        console.log("flick2 wheel", image.scale )
                                        image.scale += image.scale * wheel.angleDelta.y / 120 / 10;
                                        if(image.scale<0.1)
                                        {
                                            image.scale=0.1
                                        }
                                        else if(image.scale>10)
                                        {
                                            image.scale=10
                                        }
                                    }
                                }
                            }
                        }
    
    sierdzioS 1 Reply Last reply
    0
    • Y ynatynat

      I would like to zoom image like google maps.
      With Google Maps, the location user want to enlarge (the location where the cursor is placed) is always displayed at the same position and zoomed.
      How to do?

                          Rectangle{
                              id:image_wrapper
                              width:parent.width*0.8
                              height:parent.height
                              anchors.left: btn_back.right
      
                              color:"cyan"
                              border.color:"blue"
                              clip:true
                              Image {
                                  id: image
                                  anchors.centerIn: parent
                                  fillMode: Image.PreserveAspectFit
                                  source: contextLoadImages.imageSource
                                  antialiasing: true
                              }
                          }
      
      
                          Flickable{
                              id:flick2
                              anchors.fill:image_wrapper
      
                              PinchArea{
                                  anchors.fill: parent
                                  pinch.target: image
                                  pinch.minimumScale: 0.1
                                  pinch.maximumScale: 10
                                  pinch.dragAxis: Pinch.XAndYAxis
                                  onPinchStarted:{
                                       // not called
                                  }
                                  onSmartZoom: {
                                      // not called
      
                                  }
                                  MouseArea{
                                      id:mousearea
                                      anchors.fill: parent
                                      drag.target: image
                                      drag.axis: Drag.XAndYAxis
                                      hoverEnabled: true
                                      scrollGestureEnabled: false// 2-finger-flick gesture should pass through to the Flickable (@ Example:photo surface)
                                      onPressed:{
                                          image.anchors.centerIn=undefined
                                          
                                      }
                                      onPositionChanged: {
                                          //console.log("xy=",mouse.x, mouse.y  )
                                          //let pos = mapToItem(image, mouse.x, mouse.y)
      
                                      }
      
                                      onWheel: {
                                          console.log("flick2 wheel", image.scale )
                                          image.scale += image.scale * wheel.angleDelta.y / 120 / 10;
                                          if(image.scale<0.1)
                                          {
                                              image.scale=0.1
                                          }
                                          else if(image.scale>10)
                                          {
                                              image.scale=10
                                          }
                                      }
                                  }
                              }
                          }
      
      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Your Image should be inside of your Flickable.

      (Z(:^

      Y 1 Reply Last reply
      0
      • sierdzioS sierdzio

        Your Image should be inside of your Flickable.

        Y Offline
        Y Offline
        ynatynat
        wrote on last edited by
        #3

        @sierdzio
        Thank you. I understand correct coding: Image should be placed inside Flickable.
        But previous style could zoom for now.

        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