QML 实现导航栏 类似于TabBar
来源:互联网 发布:linux脚本怎么写 编辑:程序博客网 时间:2024/05/22 06:14
利用QML实现导航栏的功能。可以自己修改相关的样式,实现完全的自定制。
代码如下
BaseButton.qml
import QtQuick 2.6import QtQuick.Controls 1.4import QtQuick.Controls.Styles 1.4import QtGraphicalEffects 1.0Rectangle{ id : navigrect; property string mtextstr: "text" function noclicked() { p1text.color = "#00CCFF"; p1text.font.bold = false; navigrect.color = "#00498C"; //navigrect.color } function onSelected() { p1text.color = "white"; p1text.font.bold = true; navigrect.color = "#1B96D1"; } x:1; anchors.verticalCenter : parent.verticalCenter width: parent.pbwidth;height: parent.pbheight radius: 8 color: "#00498C" border.color: "#06E4F3" Text { id : p1text anchors.centerIn : parent color: "#00CCFF" text: mtextstr } Behavior on color{ PropertyAnimation{duration: 1000} } // color:curindex==3?GColor.浅绿色["500"]:GColor.浅蓝色["500"]}
MButton.qml
import QtQuick 2.6import QtQuick.Controls 1.4import QtQuick.Controls.Styles 1.4import QtGraphicalEffects 1.0Rectangle{ id : navigationrect x: 100 ; y:100; width: 200 ; height: 50; color: "#052641" border.color: "#00498C" function setDefeat() { p1.noclicked(); p2.noclicked(); p3.noclicked(); p4.noclicked(); p5.noclicked(); } property int pbwidth: 100 property int pbheight: height-6 property int index: 0 signal buttonclicked(int index); signal buttonclickedStr(string textstr); BaseButton{ id:p1; mtextstr: "你好" MouseArea { anchors.fill: parent; onClicked: { setDefeat(); index = 0; parent.onSelected(); buttonclicked(index); buttonclickedStr(parent.mtextstr); } } } BaseButton{ id:p2 x: pbwidth MouseArea { anchors.fill: parent; onClicked: { setDefeat(); index = 1; parent.onSelected(); buttonclicked(index); buttonclickedStr(parent.mtextstr); } } } BaseButton{ id:p3 x: pbwidth*2 MouseArea { anchors.fill: parent; onClicked: { setDefeat(); index = 2; parent.onSelected(); buttonclicked(index); buttonclickedStr(parent.mtextstr); } } } BaseButton{ id:p4 x: pbwidth*3 MouseArea { anchors.fill: parent; onClicked: { setDefeat(); index = 3; parent.onSelected(); buttonclicked(index); buttonclickedStr(parent.mtextstr); } } } BaseButton{ id:p5 x: pbwidth*4 MouseArea { anchors.fill: parent; onClicked: { setDefeat(); index = 4; parent.onSelected(); buttonclicked(index); buttonclickedStr(parent.mtextstr); } } } Rectangle { id : bottomrect color: "yellow"; width: pbwidth-1; height: 2 y:pbheight+2; x:index*pbwidth Behavior on x{ PropertyAnimation{duration: 500} } }}
阅读全文
0 0
- QML 实现导航栏 类似于TabBar
- sencha touch 模仿tabpanel导航栏TabBar的实现代码
- 导航栏样式、tabBar导航栏
- QML侧边伸缩导航栏
- QML侧边伸缩导航栏
- QML之TabBar
- 导航栏+tabBar的使用
- 微信小程序入门四: 导航栏样式、tabBar导航栏
- 微信小程序-导航栏样式、tabBar导航栏
- Android DrawerLayout和Navigationview实现类似于QQ的侧面导航
- Swift UI专项训练34 TabBar底部导航栏
- UITabBarController(菜单栏)带导航栏的tabBar
- iOS 顶部导航栏字体、颜色 底部tabbar颜色
- 解决UINavigationBar导航栏 和 tabBar 菜单栏上面平铺视图
- 状态栏 导航栏 tabbar背景色&字体颜色设置
- iPhone或iTouch的tabbar高,导航栏高
- 设置tabBar、导航栏背景的一些小方法等等
- iOS去除导航栏和tabbar的1px横线
- 【洛谷1892】团伙 并查集
- Git Notes——Git 分支
- C++ 常用的一些基本函数(通过书写来理解)
- 局部敏感哈希
- 最短路的三种算法(Floyd、Dijkstra、SPFA)
- QML 实现导航栏 类似于TabBar
- IT与风投
- ztree同步加载数据
- 锐浪报表,子报表没数据的原因
- 获取Linux系统信息
- 2017 icpc Southeast USA D 题 Gym
- 【Android ContentProvider 一】关于ContactsContract.CommonDataKinds.Phone.CONTENT_URI的一点理解
- CorelDRAW X6经典不会重演
- network中的weight initialization