QML之加速器仪表盘
1.QML 代码如下
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Extras 1.4
import QtQuick.Controls 2.15Window {width: 640height: 480visible: truetitle: qsTr("Hello World")CircularGauge {id:circular_gaugevalue: accelerating ? maximumValue : 0anchors.centerIn: parentproperty bool accelerating: falseKeys.onSpacePressed: {accelerating = truelabel1.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:label1anchors.top: circular_gauge.bottom}
}
2.执行结果
