当前位置:网站首页>QML control type: tabbar
QML control type: tabbar
2022-06-28 11:23:00 【Friendly, friend】
One 、 describe
TabBar Inherited from Container. Provides a label based navigation model . Allow users to switch between different views or subtasks .

TabBar Filled TabButton Control , Can work with any provider currentIndex Property or container control , for example StackLayout or SwipeView.
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
TabBar {
id: bar
width: parent.width
TabButton {
text: qsTr("Home")
}
TabButton {
text: qsTr("Discover")
}
TabButton {
text: qsTr("Activity")
}
}
StackLayout {
width: parent.width
currentIndex: bar.currentIndex
Item {
id: homeTab
}
Item {
id: discoverTab
}
Item {
id: activityTab
}
}
}
TabBar Usually populated with a set of static tab buttons , These buttons are defined inline as TabBar Children of .
1.1、 Resize labels
By default ,TabBar Will resize its buttons to fit the width of the control , Free space is allocated equally to each button . You can override the default resizing behavior by setting an explicit width for the button .
The following example shows how to keep each tab button at its implicit size , Instead of resizing to fit the tab bar :
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
TabBar {
id: bar
width: parent.width
TabButton {
text: "First"
width: implicitWidth
}
TabButton {
text: "Second"
width: implicitWidth
}
TabButton {
text: "Third"
width: implicitWidth
}
}
StackLayout {
width: parent.width
currentIndex: bar.currentIndex
Item {
id: homeTab
}
Item {
id: discoverTab
}
Item {
id: activityTab
}
}
} 
1.2、 Flick the label
If the total width of the button exceeds the available width of the label bar , It will automatically become flickable .
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
TabBar {
id: bar
width: parent.width
Repeater {
model: ["First", "Second", "Third", "Fourth", "Fifth"]
TabButton {
text: modelData
width: Math.max(100, bar.width / 5)
}
}
}
StackLayout {
width: parent.width
currentIndex: bar.currentIndex
Item {
id: homeTab
}
Item {
id: discoverTab
}
Item {
id: activityTab
}
}
}
Two 、 Attribute members
1、contentHeight : real / contentWidth : real
Content height / Width . Used to calculate TabBar Total implicit height of / Width .
2、position : enumeration
TabBar The location of . The default is style specific .
- TabBar.Header: Top , As a window or page title .
- TabBar.Footer: Bottom , As a window or page footer .
If TabBar Is specified as ApplicationWindow or Page Header or footer of , The appropriate position will be automatically set .
3、 ... and 、 Additional attribute members
1、【 read-only 】TabBar.index : int
TabBar Each of them TabButton The index of . It's attached to TabBar Each TabButton.
2、【 read-only 】TabBar.position : enumeration
TabBar The location of . It's attached to TabBar Each TabButton.
3、【 read-only 】TabBar.tabBar : TabBar
Manage this TabButton Of TabBar . It's attached to TabBar Each TabButton.
边栏推荐
猜你喜欢

人人都可以参与开源!龙蜥社区最不容错过的开发者活动来了

Remote connection of raspberry pie in VNC viewer mode without display

阿里三面:LEFT JOIN关联表中用ON还是WHERE跟条件有什么区别

Characteristics of solar wireless LED display

Spatial-Temporal时间序列预测建模方法汇总

太阳能无线LED显示屏的特点

Practice and Thinking on the architecture of a set of 100000 TPS im integrated message system

AGCO AI frontier promotion (6.28)

2022中国信通院首届业务与应用安全发展论坛成功召开!

利用soapUI获取freemarker的ftl文件模板
随机推荐
MytipartFile与File的相互转换
智联招聘基于 Nebula Graph 的推荐实践分享
合约量化交易系统开发 | 合约量化APP开发(现成案例)
JS基础4
JS foundation 4
【实战】1364- 实现一个完美的移动端瀑布流组件(附源码)
论文阅读 (59):Keyword-Based Diverse Image Retrieval with Variational Multiple Instance Graph
How to distinguish and define DQL, DML, DDL and DCL in SQL
JS基础2
字符串 & 堆 & 方法区
买股票在中金证券经理的开户二维码上开户安全吗?求大神赐教
Compareto() and equals() methods of BigDecimal class
Metersphere uses JS to refresh the current page
[sword finger offer] 49 Ugly number
New listing of operation light 3.0 - a sincere work of self subversion across the times!
《运营之光3.0》全新上市——跨越时代,自我颠覆的诚意之作!
Machine learning project captcha based on verification code recognition_ Trainer operation practice
时间戳和date转换「建议收藏」
Redis6 一:Nosql引入、Redis可以解决什么问题?
2022 开源软件安全状况报告:超41%的企业对开源安全没有足够的信心