利用QML实现导航栏的功能。可以自己修改相关的样式,实现完全的自定制。

代码如下
BaseButton.qml

import QtQuick 2.6
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import 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.verticalCenterwidth: parent.pbwidth;height: parent.pbheightradius: 8color: "#00498C"border.color: "#06E4F3"Text {id : p1textanchors.centerIn : parentcolor: "#00CCFF"text: mtextstr}Behavior on color{PropertyAnimation{duration: 1000}}// color:curindex==3?GColor.浅绿色["500"]:GColor.浅蓝色["500"]
}

MButton.qml

import QtQuick 2.6
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtGraphicalEffects 1.0Rectangle{id : navigationrectx: 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: 100property int pbheight: height-6property int index: 0signal 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:p2x: pbwidthMouseArea{anchors.fill: parent;onClicked: {setDefeat();index = 1;   parent.onSelected();buttonclicked(index);buttonclickedStr(parent.mtextstr);}}}BaseButton{id:p3x: pbwidth*2MouseArea{anchors.fill: parent;onClicked: {setDefeat();index = 2; parent.onSelected();buttonclicked(index);buttonclickedStr(parent.mtextstr);}}}BaseButton{id:p4x: pbwidth*3MouseArea{anchors.fill: parent;onClicked: {setDefeat();index = 3;parent.onSelected();buttonclicked(index);buttonclickedStr(parent.mtextstr);}}}BaseButton{id:p5x: pbwidth*4MouseArea{anchors.fill: parent;onClicked: {setDefeat();index = 4;parent.onSelected();buttonclicked(index);buttonclickedStr(parent.mtextstr);}}}Rectangle{id : bottomrectcolor: "yellow";width: pbwidth-1; height: 2y:pbheight+2;x:index*pbwidthBehavior on x{PropertyAnimation{duration: 500}}}
}

QML 实现导航栏 类似于TabBar相关推荐

  1. iOS 准确获取 iPhone 状态栏、导航栏、TabBar高度,看这篇就够了

    前言 最近在项目开发的时候,发现项目提供的获取 「状态栏+导航栏高度」的方法,在 iPhone 12 系列机型上是错误的.解决了这个问题之后,决定做个简单的总结,于是有了这篇文章. 本文主要是分析了遇 ...

  2. 最全最准确获取iOS 状态栏、导航栏、TabBar高度

    前言 最近在iPhone 12 系列机型上开发项目时,发现使用项目提供的获取状态栏.导航栏高度方法获取到的高度是错误的,随后跟踪排查最终解决这个问题,所以自己想简单的总结一下问题原因和解决办法. 本文 ...

  3. [转载]uni-app 换肤实现-原生导航栏、tabbar和页面全部替换

    通过全局缓存参数设置当前主题: 换肤代码如下 setSkinme(theme) {uni.setStorageSync("theme", theme)uni.showModal({ ...

  4. iOS去除导航栏和tabbar的横线

    导航[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetri ...

  5. 【Flutter】顶部导航栏实现 ( Scaffold | DefaultTabController | TabBar | Tab | TabBarView )

    文章目录 一.Scaffold 组件 二.实现顶部导航栏 三.DefaultTabController 导航标签控制组件 四.TabBar 导航按钮组件 五.Tab 标签组件 六.TabBarView ...

  6. 微信小程序不同身份登录,显示不同的tabbar(导航栏)

    微信小程序,不同身份登录不同的底部导航栏.初次遇到这个问题,菜鸟的我没有一丝丝头绪,看了几篇博客后,终于明白了.下面是总结的模板,拿去直接用就欧克. 比如一个小程序需要两个版本(用户版.商家版),并且 ...

  7. 快应用底部导航栏的原生实现

    什么是快应用 快应用是一种不需要安装即可使用,类似于原生APP的新型应用形态,它是由手机厂商联合推出的一款产品.它不依赖于App,而是依赖于各大手机厂商自带的快应用加载器,使用极其方便. 快应用的官方 ...

  8. 微信小程序自定义导航栏与自带下拉刷新冲突

    在使用HbuilderX开发微信小程序时(在HbuilderX中写代码,在微信开发者工具编译),由于微信小程序自带的导航栏功能少,样式单一等,于是采用colorUI自定义导航栏实现需求.而问题就一而再 ...

  9. 说一说要求 小程序自定义导航栏 的需求有多沙雕

    小程序是一种新的开放能力,开发者可以快速地开发一个小程序.小程序可以在 超级App 内被便捷地获取和传播,同时具有出色的使用体验. 在小程序项目中 自定义导航栏 绝对算得上是最恶心的需求之一.本篇文章 ...

最新文章

  1. Hadoop学习笔记(1) ——菜鸟入门
  2. web性能优化之事件节流
  3. ActiveSupport::Concern 和 gem 'name_of_person'(300✨) 的内部运行机制分析
  4. 东莞华勤通讯软件测试怎么样,【社招】华勤通讯NBD测试验证部急聘岗位-东莞...
  5. OpenShift 4 之Istio-Tutorial (10) 访问白名单、黑名单
  6. 软件工程学习总结(2)——大部分的软件工程其实就是管道作业
  7. python能做什么毕业设计-有没有适合python做的毕设题目,现在不知道做什么了?...
  8. reactor线程模型_面试一文搞定JAVA的网络IO模型
  9. 文件标准标准IO与文件IO 的区别
  10. linux后台运行和关闭、查看后台任务(转)
  11. mysql client 升级_升级MySQL (参考MySQL官方文档)
  12. 白盒测试方法和黑盒测试方法
  13. 软件工程第二篇博客(“相等”)
  14. 用几何画板演示高尔顿钉板动画
  15. HoG特征以及SVM的配合
  16. 《大秦帝国》第四部,阵容太强大
  17. 最新最全张家界旅游攻略(您必须知道的张家界攻略)
  18. 从零开始一套完整的短视频运营方案,想做抖音快手短视频的速来观摩。
  19. 计算s=1+1/2+1/3+…+1/n。当n足够大s>k,求n
  20. “我们“App功能介绍

热门文章

  1. 前端面经 - 看这篇就够了(已拿offer)
  2. 3ds Max 2011\2012下载及安装方法
  3. crmeb多商户二开文档
  4. 它需要一个平台才能实现6代Wi-Fi互联,可为第十代平台提供连接
  5. 【备份专题】备份软件方案可靠性解析
  6. 疯狂Python讲义Unit4Test
  7. 搭建ipv6有状态dhcp服务器,Centos 7下IPV6 有状态DHCPV6配置
  8. cdh 差异_CDH5和6的区别
  9. 拿起相机,便是最好的艺术疗愈
  10. 森林生态旅游与康养类毕业论文文献都有哪些?