T_BreadcrumbBar.qml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Layouts
  4. import QtQuick.Window
  5. import FluentUI
  6. import "../component"
  7. FluScrollablePage{
  8. title:"BreadcurmbBar"
  9. leftPadding:10
  10. rightPadding:10
  11. bottomPadding:20
  12. spacing: 0
  13. Component.onCompleted: {
  14. var items = []
  15. for(var i=0;i<10;i++){
  16. items.push({title:"Item_"+(i+1)})
  17. }
  18. breadcrumb_1.items = items
  19. breadcrumb_2.items = items
  20. }
  21. FluArea{
  22. Layout.fillWidth: true
  23. height: 68
  24. paddings: 10
  25. Layout.topMargin: 20
  26. FluBreadcrumbBar{
  27. id:breadcrumb_1
  28. width:parent.width
  29. anchors.verticalCenter: parent.verticalCenter
  30. onClickItem:
  31. (model)=>{
  32. showSuccess(model.title)
  33. }
  34. }
  35. }
  36. FluArea{
  37. Layout.fillWidth: true
  38. height: 100
  39. paddings: 10
  40. Layout.topMargin: 20
  41. ColumnLayout{
  42. anchors.verticalCenter: parent.verticalCenter
  43. width:parent.width
  44. spacing: 10
  45. FluFilledButton{
  46. text:"Reset sample"
  47. onClicked:{
  48. var items = []
  49. for(var i=0;i<10;i++){
  50. items.push({title:"Item_"+(i+1)})
  51. }
  52. breadcrumb_2.items = items
  53. }
  54. }
  55. FluBreadcrumbBar{
  56. id:breadcrumb_2
  57. separator:">"
  58. spacing:8
  59. textSize:18
  60. Layout.fillWidth: true
  61. onClickItem:
  62. (model)=>{
  63. //不是点击最后一个item元素
  64. if(model.index+1!==count()){
  65. breadcrumb_2.remove(model.index+1,count()-model.index-1)
  66. }
  67. showSuccess(model.title)
  68. }
  69. }
  70. }
  71. }
  72. CodeExpander{
  73. Layout.fillWidth: true
  74. Layout.topMargin: -1
  75. code:'FluBreadcrumbBar{
  76. width:parent.width
  77. separator:">"
  78. spacing:8
  79. textSize:18
  80. onClickItem: (model)=>{
  81. }
  82. }'
  83. }
  84. }