上一個原文鏈接http://blog.csdn.net/z609932088/article/details/53946245javascript
參考資料鏈接:連接: https://pan.baidu.com/s/1pLjOTWB 密碼: t9d1java
惟一的問題就是在繪製儀表指針的時候有鋸齒ui
換成qml能夠消除鋸齒,可是我對qml不熟練啊,(┬_┬).net
這裏摸索出來一個間的界面,就是在aml加一個定時器,來改變角度指針
上源代碼orm
import QtQuick 2.7 import QtQuick.Window 2.2 Window { id:root visible: true width: 1920 height: 720 title: qsTr("Car Play") color: "#161616" property int pointer_angle: -135 property bool timeChangedFlag: true function timeChanged() { if(timeChangedFlag) { if(pointer_angle<135) { pointer_angle++ if(pointer_angle == 135) { timeChangedFlag = false } } } if(!timeChangedFlag) { if(pointer_angle>-135) { pointer_angle-- if(pointer_angle == -135) { timeChangedFlag = true } } } } Timer{ id:pointer_timer interval: 40 running: true repeat: true onTriggered: root.timeChanged() } Item { id: background width: root.width height: root.height anchors.centerIn: parent Image { id: background_image source: "qrc:/source/beijing.bmp" } Image { id: pointer x:920 y:90 transform: Rotation{ origin.x:40 origin.y:267 angle: pointer_angle } source: "qrc:/source/222.png" } } }