FluentUI/example/T_TabView.qml

114 lines
3.3 KiB
QML
Raw Normal View History

2023-03-27 18:24:35 +08:00
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import FluentUI 1.0
FluScrollablePage{
title:"TabView"
2023-03-28 17:53:46 +08:00
leftPadding:10
rightPadding:10
bottomPadding:20
2023-03-27 18:24:35 +08:00
2023-03-30 11:43:35 +08:00
property var colors : [FluColors.Yellow,FluColors.Orange,FluColors.Red,FluColors.Magenta,FluColors.Purple,FluColors.Blue,FluColors.Teal,FluColors.Green]
2023-03-27 22:58:33 +08:00
Component{
id:com_page
Rectangle{
anchors.fill: parent
color: argument
}
}
2023-03-30 11:43:35 +08:00
function newTab(){
tab_view.appendTab("qrc:/res/image/favicon.ico","Document "+tab_view.count(),com_page,colors[Math.floor(Math.random() * 8)].dark)
}
2023-03-27 22:58:33 +08:00
Component.onCompleted: {
2023-03-30 11:43:35 +08:00
newTab()
newTab()
newTab()
2023-03-27 22:58:33 +08:00
}
2023-03-27 18:24:35 +08:00
FluArea{
width: parent.width
Layout.topMargin: 20
2023-03-30 11:43:35 +08:00
height: 50
2023-03-27 18:24:35 +08:00
paddings: 10
2023-03-30 11:43:35 +08:00
RowLayout{
spacing: 14
FluDropDownButton{
id:btn_tab_width_behavior
Layout.preferredWidth: 140
text:"Equal"
items:[
FluMenuItem{
text:"Equal"
onClicked: {
btn_tab_width_behavior.text = text
tab_view.tabWidthBehavior = FluTabView.Equal
}
},
FluMenuItem{
text:"SizeToContent"
onClicked: {
btn_tab_width_behavior.text = text
tab_view.tabWidthBehavior = FluTabView.SizeToContent
}
},
FluMenuItem{
text:"Compact"
onClicked: {
btn_tab_width_behavior.text = text
tab_view.tabWidthBehavior = FluTabView.Compact
}
}
]
}
FluDropDownButton{
id:btn_close_button_visibility
text:"Always"
Layout.preferredWidth: 120
items:[
FluMenuItem{
text:"Nerver"
onClicked: {
btn_close_button_visibility.text = text
tab_view.closeButtonVisibility = FluTabView.Nerver
}
},
FluMenuItem{
text:"Always"
onClicked: {
btn_close_button_visibility.text = text
tab_view.closeButtonVisibility = FluTabView.Always
}
},
FluMenuItem{
text:"OnHover"
onClicked: {
btn_close_button_visibility.text = text
tab_view.closeButtonVisibility = FluTabView.OnHover
}
}
]
}
}
}
2023-03-27 18:24:35 +08:00
2023-03-30 11:43:35 +08:00
FluArea{
width: parent.width
Layout.topMargin: 5
height: 400
paddings: 10
2023-03-27 18:24:35 +08:00
FluTabView{
2023-03-27 22:58:33 +08:00
id:tab_view
2023-03-30 11:43:35 +08:00
onNewPressed:{
newTab()
}
2023-03-27 18:24:35 +08:00
}
}
}