QML - 动态柱状图
此博客始创于:http://blog.youkuaiyun.com/lys211
转载请注明出处
效果图:
文件结构:
首先,这个并不是真的频谱柱状图,只是用随机数来实现的数组数据
Timer{
interval: 500;
repeat: true;
running: true;
onTriggered: {
if(barObject.length > 0){ //生成随机数
for(var i = 0; i < barCount; i++){
barObject[i].barHeight = Math.random()*root.height;
}
}
else
{
root.createBarArea();
}
}
}
BarGraphArea.qml文件内容:
import QtQuick 2.0
Rectangle {
id:root
width: 200
height: 100