如何在 qml 中禁用鼠标区域的拖动动画,但我想处理从 0 拖动到项目高度时的 yvlaue 变化

如何在 qml 中禁用鼠标区域的拖动动画,但我想处理从 0 拖动到项目高度时的 yvlaue 变化

导入 QtQuick 2.15 导入 QtQuick.Window 2.15

窗口 { 宽度:640 高度:480 可见:true 标题:qsTr(“Hello World”)

Item {
    id: _item
    width: 100; height: 50;

    Rectangle {
        anchors.fill: parent
        color: "lightblue"
    }

    MouseArea {
        id: mouseA
        anchors.fill: parent
        drag.target: _item
        drag.axis: Drag.YAxis
        drag.minimumY: 0
        drag.maximumY: _item.height

        // Ensure initialY is set correctly after potential initial height of 0
        property int initialY: _item.height
        property int yValue: _item.y

        onYValueChanged: {
            console.log("Mani Y value changed to:"+ yValue +" "+initialY);
            if (drag.active && initialY == yValue){
                console.log("Mani Y value changed to:"+initialY);
            }
        }
    }

}

}

相关内容