基本结构
import QtQuick
import QtQuick.Controls.Basic
ApplicationWindow {
id: root; visible: true
width: 200; height: 100
title: "ApplicationWindow 属性"
/*-----菜单/工具栏区域-----*/
menuBar: MenuBar {
}
}
}
基本结构
menuBar: MenuBar {
Menu{
title: qsTr("文件")
//子项菜单
Action {
text: qsTr("新建")
onTriggered: {console.log("新建")} //点击信号
}
Action {
text: qsTr("保存")
onTriggered: {console.log("保存")} //点击信号
}
}
}
}
属性
contentWidth: real
//内容高度,用于计算标签栏的总隐含高度
//如果使用 height 会导致标签文本不会垂直居中
contentHeight: real
//标签栏总宽度
//内容宽度,用于计算标签栏的总隐含宽度
position: enumeration
//标签栏的位置
//如果 TabBar 被指定为 ApplicationWindow 或 Page 的页眉或页脚,则会自动设置相应的位置
position: TabBar.Header//顶部,作为窗口或页面页眉
position: TabBar.Footer//底部,作为窗口或页面页脚
width: implicitWidth
//根据标签内容调整标签宽度
只读属性
TabBar.index: int
//每个标签按钮的索引
//读取时,读取每个标签按钮的此属性,非 TabBar 的属性
TabBar.position : enumeration
//标签栏的位置
//读取时,读取每个标签按钮的此属性,非 TabBar 的属性
TabBar.tabBar: TabBar
//此标签按钮对应的 TabBar,返回地址值
//读取时,读取每个标签按钮的此属性,非 TabBar 的属性
自定义样式
background: Rectangle {
color: "#888"//标签中间分割线
}
//TabButton 样式与 Button 样式一致