qml学习------------------TabView
来源:互联网 发布:大数据和云存储区别 编辑:程序博客网 时间:2024/04/29 06:01
本次学习了tabview的使用,tabview的使用非常简单的,但是要做出非常漂亮的TabView就很难了,就需要依靠他的TabViewStyle来自定义属性了。
import QtQuick 2.2import QtQuick.Controls 1.2import QtQuick.Controls.Styles 1.2import QtQuick.Layouts 1.1Rectangle{ width:360; height: 240; color: "lightgray"; id:root; property var icons: ["call1.png" ,"call2.png" ,"call3.png" ]; Component.onCompleted: { tabView.addTab("ABC" , tabContent); tabView.addTab("BCD" , tabContent); tabView.addTab("CDE" , tabContent); tabView.addTab("DEF" , tabContent); } Component{ id: tabContent; Rectangle{ implicitWidth: 100; implicitHeight: 100; anchors.fill: parent; color: Qt.rgba(Math.random() , Math.random() , Math.random() ); } } TabView{ id: tabView; anchors.fill: parent; style: TabViewStyle{ tab: Item{ implicitWidth: Math.max(text.width + 8 , 80 ); implicitHeight: 48; //被选中状态下的item Rectangle{ width: (styleData.index < control.count - 1 ) ? (parent.width - 2 ):parent.width; height: parent.height - 4; anchors.top: parent.top; anchors.left: parent.left; anchors.leftMargin: 1; visible: styleData.selected; gradient: Gradient{ GradientStop{position: 0.0 ; color:"#606060";} GradientStop{position: 0.5 ; color:"#c0c0c0";} GradientStop{position: 1.0 ; color:"#a0a0a0";} } } //未选中的状态 Rectangle{ width: 2; height: parent.height - 4; anchors.top: parent.top; anchors.right: parent.right; visible: styleData.index < control.count - 1; gradient: Gradient{ GradientStop{position: 0.0 ; color:"#404040";} GradientStop{position: 0.5 ; color:"#707070";} GradientStop{position: 1.0 ; color:"#404040";} } } //item的水平布局 RowLayout{ implicitWidth: Math.max( text.width , 71); height: 48; anchors.centerIn: parent; z : 1; Image{ width: 48; height: 48; source: root.icons(styleData.index%3); } Text{ id: text; text:styleData.title; color:styleData.selected ?"blue" : (styleData.hovered ? "green":"white"); } } } tabBar :Rectangle{ height: 56; gradient: Gradient{ GradientStop{position: 0.0 ; color:"#484848";} GradientStop{position: 0.3 ; color:"#787878";} GradientStop{position: 1.0 ; color:"#a0a0a0";} } Rectangle{ width: parent.width; height: 4; anchors.bottom: parent.bottom; border.width: 2; border.color: "#c7c7c7"; } } } }}
0 0
- qml学习------------------TabView
- QML学习之基本元素ProgressBar, TabView, Slider介绍
- QML tabview使用
- QML之TabView
- Qml TabView 如何动态创建Tab
- IOS-TabView学习
- tabview
- qml 学习
- QML学习
- Appcan学习——tabview 静止页面左右滑动切换
- IOS学习(十四)城市级联操作(两个tabview)
- QML学习:QML文件当做组件使用
- QML学习摘录 01:初识QML
- QML学习(1)
- QML学习(2)
- QML学习(3)
- qml学习入门资料
- qml入门学习小结
- 哈希表
- rsync使用
- 提升SQLite数据插入效率低、速度慢的方法
- ASM磁盘故障诊断
- Inno Setup 快速打包应用程序 简单 软件打包发行的使用说明
- qml学习------------------TabView
- Android之地图
- Eclipse安装SVN插件
- charles使用教程指南
- [LeetCode] Palindrome Number & Valid Palindrome - 回文系列问题
- Hibernate Criteria 多层次查询关联问题
- 如何分辨周围聪明人(转自知乎)
- 通过Animator实现弧形弹出菜单
- RedHat Linux6.5 使用CentOS yum源