Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. 在flickabke 中用scale 进行非中心点的缩放,导致图片有些部分不能拖拽回来
Forum Update on Monday, May 27th 2025

在flickabke 中用scale 进行非中心点的缩放,导致图片有些部分不能拖拽回来

Scheduled Pinned Locked Moved Solved Chinese
2 Posts 1 Posters 1.0k 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.
  • J Offline
    J Offline
    jimfar
    wrote on last edited by
    #1

    import QtQuick.Window 2.2
    import QtQuick 2.0
    Window {
    id:root1
    visible: true
    width: 600
    height: 600
    title: qsTr("Hello World")
    property double lastContentXdelta:0
    property double lastContentYdelta:0
    MouseArea{
    id: dragRegion1
    anchors.fill: parent
    onWheel : {
    if (wheel.modifiers & Qt.ControlModifier){
    // prevcenter=tform.origin;
    if (wheel.angleDelta.y > 0)
    {

                tform.xScale += 0.01
                tform.yScale += 0.01
            }
            else
            {
                if( tform.xScale>0.01){
                    tform.xScale -= 0.01
                    tform.yScale -= 0.01
    
                }
    
    
            }
    
    
        }
        else{
            wheel.accepted=false
        }
    }
    // Attach scrollbars to the right and bottom edges of the view.
    ScrollBar {
        id: verticalScrollBar
        width: 12; height: flickview.height
        anchors.right: flickview.right
        opacity: 1
        z:1000;
        orientation: Qt.Vertical
        position: (flickview.contentY - flickview.originY) * (flickview.height / flickview.contentHeight)
        pageSize: flickview.visibleArea.heightRatio
        //targetflick:flickview
    
    }
    
    ScrollBar {
        id: horizontalScrollBar
        width: flickview.width; height: 12
        anchors.bottom: flickview.bottom
        opacity: 1
        z:1000;
        orientation: Qt.Horizontal
        position: (flickview.contentX - flickview.originX) * (flickview.width / flickview.contentWidth)
        pageSize: flickview.visibleArea.widthRatio
        // targetflick:flickview
    
    }
    
    // Create a flickable to view a large image.
    Flickable {
        id: flickview
        leftMargin: 10
        anchors.fill: parent
        contentWidth: picture.width*tform.xScale
        contentHeight: picture.height*tform.yScale
        onContentWidthChanged: {
            // flickview.originX-=(flickview.width-flickview.width*tform.xScale )/2
    
        }
        onContentHeightChanged: {
             //flickview.originY-=(flickview.height-flickview.height*tform.xScale )/2
        }
        Image {
            id: picture
            source: "./pics/niagara_falls.jpg"
            asynchronous: true
            transform: Scale {
                id: tform
                origin.x:  flickview.contentX +flickview.width/2
                origin.y: flickview.contentY +flickview.height/2
                xScale: 1
                yScale: 1
            }
            Component.onCompleted:
            {
    
            }
        }
    
        // Only show the scrollbars when the view is moving.
        states: State {
            name: "ShowBars"
            when: view.movingVertically || view.movingHorizontally
            PropertyChanges { target: verticalScrollBar; opacity: 1 }
            PropertyChanges { target: horizontalScrollBar; opacity: 1 }
        }
    
        transitions: Transition {
            NumberAnimation { properties: "opacity"; duration: 400 }
        }
    }
    

    }

    }

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jimfar
      wrote on last edited by
      #2

      ok it resolved by using this QuickQanava library

      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