1.QML 代码如下
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Extras 1.4
import QtQuick.Controls 2.15
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
CircularGauge {
id:circular_gauge
value: accelerating ? maximumValue : 0
anchors.centerIn: parent
property bool accelerating: false
Keys.onSpacePressed: {
accelerating = true
label1.text = circular_gauge.value
}
Keys.onReleased: {
if (event.key === Qt.Key_Space) {
accelerating = false;
event.accepted = true;
}
}
Component.onCompleted: forceActiveFocus()
Behavior on value {
NumberAnimation {
duration: 1000
}
}
}
Label{
id:label1
anchors.top: circular_gauge.bottom
}
}
2.执行结果