如果要测量更改时间,则必须执行与y相同的过程,将最后一次保存在内存中:
import QtQuick 2.12
Rectangle {
width: 15; height: 65
property bool yUwards: false
property bool yDwards: false
property real oldY: y
property double last_time: new Date().getTime()
onYChanged: {
var current_time = new Date().getTime()
console.log("Time = ", current_time - last_time)
if (y > oldY)
yDwards = true
else if (y < oldY)
yUwards = true
oldY = y
last_time = current_time
}
MouseArea {
anchors.fill: parent
anchors.margins: -parent.height
drag.target: parent
drag.axis: Drag.YAxis
drag.minimumY: table.y
drag.maximumY: table.height - parent.height + 10
}
}