2023-08-24 15:50:37 +08:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import QtQuick.Window
|
|
|
|
import QtQuick.Controls
|
|
|
|
import FluentUI
|
|
|
|
import "qrc:///example/qml/component"
|
|
|
|
|
|
|
|
FluScrollablePage {
|
|
|
|
|
|
|
|
title:"TreeView"
|
|
|
|
|
2023-09-14 18:50:36 +08:00
|
|
|
function treeData(){
|
|
|
|
const dig = (path = '0', level = 4) => {
|
|
|
|
const list = [];
|
2023-09-15 01:28:03 +08:00
|
|
|
for (let i = 0; i < 6; i += 1) {
|
2023-09-14 18:50:36 +08:00
|
|
|
const key = `${path}-${i}`;
|
|
|
|
const treeNode = {
|
|
|
|
title: key,
|
|
|
|
key,
|
|
|
|
};
|
|
|
|
if (level > 0) {
|
|
|
|
treeNode.children = dig(key, level - 1);
|
|
|
|
}
|
|
|
|
list.push(treeNode);
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
};
|
|
|
|
return dig();
|
|
|
|
}
|
|
|
|
|
2023-08-24 15:50:37 +08:00
|
|
|
FluArea{
|
|
|
|
Layout.fillWidth: true
|
2023-09-15 01:28:03 +08:00
|
|
|
Layout.topMargin: 10
|
2023-08-24 15:50:37 +08:00
|
|
|
paddings: 10
|
2023-09-15 01:28:03 +08:00
|
|
|
height: 60
|
|
|
|
FluText{
|
|
|
|
text:"共计:%1条数据".arg(tree_view.count())
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2023-08-24 15:50:37 +08:00
|
|
|
}
|
|
|
|
}
|
2023-09-15 01:28:03 +08:00
|
|
|
|
2023-08-24 15:50:37 +08:00
|
|
|
FluArea{
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: 10
|
|
|
|
paddings: 10
|
|
|
|
height: 400
|
|
|
|
FluTreeView{
|
|
|
|
id:tree_view
|
|
|
|
width:240
|
|
|
|
anchors{
|
|
|
|
top:parent.top
|
|
|
|
left:parent.left
|
|
|
|
bottom:parent.bottom
|
|
|
|
}
|
2023-09-14 18:50:36 +08:00
|
|
|
Component.onCompleted: {
|
|
|
|
var data = treeData()
|
|
|
|
dataSource = data
|
|
|
|
}
|
|
|
|
}
|
2023-08-24 15:50:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CodeExpander{
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: -1
|
|
|
|
code:'FluTreeView{
|
|
|
|
id:tree_view
|
|
|
|
width:240
|
|
|
|
height:600
|
|
|
|
Component.onCompleted: {
|
2023-09-15 01:28:03 +08:00
|
|
|
var data = treeData()
|
|
|
|
dataSource = data
|
2023-08-24 15:50:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
'
|
|
|
|
}
|
|
|
|
}
|