具体方法:

https://www.cnblogs.com/judes/p/11359243.html

qml:

import QtQuick 2.0
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.3
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick 2.7
Item {
signal clickIndex(int index) Rectangle {
id: tab_btn
width:
height: parent.height
color: "black"
gradient: Gradient {
GradientStop { position: 0.0; color: "#292929" }
GradientStop { position: 1.0; color: "#828282" }
} Column {
id: colomn_btn
anchors.fill: parent
spacing:
Rectangle {
id:btn_1
width: parent.width
height: width
color: "gray"
Text {
id: text_1_1
anchors.centerIn: parent
color:"white"
font.family: "FontAwesome"
text: "\uf037"
font.pixelSize:
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: text_1_1.bottom
anchors.topMargin:
color:"white"
text: "汇总界面"
font.pixelSize:
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
clickIndex()
btn_1.color="#899dc6"
btn_2.color="gray"
btn_3.color="gray"
btn_4.color="gray"
btn_5.color="gray"
btn_6.color="gray"
}
onPressed: {
text_1_1.color="black"
}
onReleased: {
text_1_1.color="white"
}
onEntered: {
if(parent.color!="#899dc6")
{
parent.color="#c3c4c6"
}
}
onExited: {
if(parent.color!="#899dc6")
{
parent.color="gray"
}
}
}
}
Rectangle {
id:btn_2
width: parent.width
height: width
color: "gray"
Text {
id: text_2_1
anchors.centerIn: parent
color:"white"
font.family: "FontAwesome"
text: "\uf037"
font.pixelSize:
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: text_2_1.bottom
anchors.topMargin:
color:"white"
text: "状态监测"
font.pixelSize:
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
clickIndex()
btn_1.color="gray"
btn_2.color="#899dc6"
btn_3.color="gray"
btn_4.color="gray"
btn_5.color="gray"
btn_6.color="gray"
}
onPressed: {
text_2_1.color="black"
}
onReleased: {
text_2_1.color="white"
}
onEntered: {
if(parent.color!="#899dc6")
{
parent.color="#c3c4c6"
}
}
onExited: {
if(parent.color!="#899dc6")
{
parent.color="gray"
}
}
}
}
Rectangle {
id:btn_3
width: parent.width
height: width
color: "gray"
Text {
id: text_3_1
anchors.centerIn: parent
color:"white"
font.family: "FontAwesome"
text: "\uf037"
font.pixelSize:
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: text_3_1.bottom
anchors.topMargin:
color:"white"
text: "故障诊断"
font.pixelSize:
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
clickIndex()
btn_1.color="gray"
btn_2.color="gray"
btn_3.color="#899dc6"
btn_4.color="gray"
btn_5.color="gray"
btn_6.color="gray"
}
onPressed: {
text_3_1.color="black"
}
onReleased: {
text_3_1.color="white"
}
onEntered: {
if(parent.color!="#899dc6")
{
parent.color="#c3c4c6"
}
}
onExited: {
if(parent.color!="#899dc6")
{
parent.color="gray"
}
}
}
}
Rectangle {
id:btn_4
width: parent.width
height: width
color: "gray"
Text {
id: text_4_1
anchors.centerIn: parent
color:"white"
font.family: "FontAwesome"
text: "\uf037"
font.pixelSize:
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: text_4_1.bottom
anchors.topMargin:
color:"white"
text: "性能评估"
font.pixelSize:
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
clickIndex()
btn_1.color="gray"
btn_2.color="gray"
btn_3.color="gray"
btn_4.color="#899dc6"
btn_5.color="gray"
btn_6.color="gray"
}
onPressed: {
text_4_1.color="black"
}
onReleased: {
text_4_1.color="white"
}
onEntered: {
if(parent.color!="#899dc6")
{
parent.color="#c3c4c6"
}
}
onExited: {
if(parent.color!="#899dc6")
{
parent.color="gray"
}
}
}
}
Rectangle {
id:btn_5
width: parent.width
height: width
color: "gray"
Text {
id: text_5_1
anchors.centerIn: parent
color:"white"
font.family: "FontAwesome"
text: "\uf037"
font.pixelSize:
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: text_5_1.bottom
anchors.topMargin:
color:"white"
text: "状态预测"
font.pixelSize:
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
clickIndex()
btn_1.color="gray"
btn_2.color="gray"
btn_3.color="gray"
btn_4.color="gray"
btn_5.color="#899dc6"
btn_6.color="gray"
} onPressed: {
text_5_1.color="black"
}
onReleased: {
text_5_1.color="white"
}
onEntered: {
if(parent.color!="#899dc6")
{
parent.color="#c3c4c6"
}
}
onExited: {
if(parent.color!="#899dc6")
{
parent.color="gray"
}
}
}
}
Rectangle {
id:btn_6
width: parent.width
height: width
color: "gray"
Text {
id: text_6_1
anchors.centerIn: parent
color:"white"
font.family: "FontAwesome"
text: "\uf037"
font.pixelSize:
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: text_6_1.bottom
anchors.topMargin:
color:"white"
text: "保障决策"
font.pixelSize:
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
clickIndex()
btn_1.color="gray"
btn_2.color="gray"
btn_3.color="gray"
btn_4.color="gray"
btn_5.color="gray"
btn_6.color="#899dc6"
}
onPressed: {
text_6_1.color="black"
}
onReleased: {
text_6_1.color="white"
}
onEntered: {
if(btn_6.color!="#899dc6")
{
btn_6.color="#c3c4c6"
}
}
onExited: {
if(btn_6.color!="#899dc6")
{
btn_6.color="gray"
}
}
}
}
}
}
}

Qt widget使用QML自定义导航栏的更多相关文章

  1. 分别用ToolBar和自定义导航栏实现沉浸式状态栏

    一.ToolBar 1.在build.gradle中添加依赖,例如: compile 'com.android.support:appcompat-v7:23.4.0' 2.去掉应用的ActionBa ...

  2. swift 自定义导航栏颜色

    func setNavigationApperance(){ //自定义导航栏颜色 [self.navigationController?.navigationBar.barTintColor = U ...

  3. ios7以上自定义导航栏标题的字体大小及颜色的方法

    自定义导航栏的字体和颜色,只需要自定义一个lable,然后将lable添加到导航栏的titleview中就可以了 代码如下 UILabel *label = [[UILabel alloc] init ...

  4. iOS 自定义导航栏笔记

    一.UINavigationBar的结构 导航栏几乎是每个页面都会碰到的问题,一般两种处理方式:1.隐藏掉不显示 2.自定义 1. 添加导航栏 TestViewController * mainVC ...

  5. 微信小程序自定义导航栏

    微信小程序需要自定义导航栏,特别是左上角的自定义设置,可以设置返回按钮,菜单按钮,配置如下: 1.在app.json的window属性中增加: navigationStyle:custom 顶部导航栏 ...

  6. iOS:自定义导航栏,随着tableView滚动显示和隐藏

    自定义导航栏,随着tableView滚动显示和隐藏 一.介绍 自定义导航栏是APP中很常用的一个功能,通过自定义可以灵活的实现动画隐藏和显示效果.虽然处理系统的导航栏也可以实现,但是这个是有弊端的,因 ...

  7. 微信小程序 - 自定义导航栏(提示)

    点击下载: 自定义导航栏示例

  8. 微信小程序——自定义导航栏

    微信头部导航栏可能通过json配置: 但是有时候我们项目需求可能需要自定义头部导航栏,如下图所示: 现在具体说一下实现步骤及方法: 步骤: 1.在 app.json 里面把 "navigat ...

  9. 微信小程序-如何自定义导航栏(navigationStyle)?

    小程序是越来越开放了,微信版本 6.6.0可以自定义导航? 先了解下app.json中window配置navigationStyle属性,即导航栏样式,仅支持 default/custom.custo ...

随机推荐

  1. 区别和认识.net四个判等方法

    概要 本方介绍.net如何判断两个对象是否相等 .Net有四个判等函数 1)Object.ReferenceEquals 2)Object.Equals 3)对象实例的Equals 4)==操作符 这 ...

  2. 为什么要使用ConcurrentHashMap

    好久没写过技术性文章了,还是要坚持下去.掌握的知识,能写出来或者是讲给别人听才是真正的掌握了知识,如果不善于给别人讲,实际上还是没有真正掌握相关的知识,挑个简单的写吧. 面试的时候经常会被问到hash ...

  3. nginx 故障转移

    当我们的服务器某台出现问题的时候,怎么办.... nginx在反向代理到真实服务器(上游服务器)的时候,如果真实服务器出现了宕机,或延迟卡顿的情况下,直接轮询下一个节点. 其中主要配置如下: ###n ...

  4. 使用unsafe改善性能

    这种方式是Go所推荐的,优点就是安全,尽管这种操作会发生内存拷贝,导致性能上会有所损耗,这在处理一般业务时这种损耗是可以忽略的.但如果是拷贝频繁的情况下,想要进行性能优化时,就需要引入unsafe.P ...

  5. mage Ansible学习3 ansible role实例

    一.ansible配置文件解析 1./etc/ansible/ansible.cfg配置文件详解 [root@node3 ~]# cat /etc/ansible/ansible.cfg |grep ...

  6. flutter报错:NoSuchMethodError: The method '>' was called on null.

    写了个list,发现出不来,报错 flutter: Another exception was thrown: RenderBox was not laid out: _RenderScrollSem ...

  7. ArcGIS Pro 性能诊断

    是否遇到过 ArcGIS Pro 显示地图很慢很卡的情况呢? 我们可以通过以下步骤来诊断和调整. 调用方法:点击当前展示缓慢的面板(可以是地图视图也可以是三维场景视图),按下键盘 Shift+E.这时 ...

  8. (1)Go变量声明、赋值和常量

     先简单了解一下控制台输出,在go中,我们使用fmt包中的函数进行在控制台中打印,一般用以下几个函数      fmt.Print()        #不换行输出      fmt.Printf()  ...

  9. 统计单词Java

    功能0:输出某个英文文本文件中 26 字母出现的频率,由高到低排列,并显示字母出现的百分比,精确到小数点后面两位. 功能1:输出文件中所有不重复的单词,按照出现次数由多到少排列,出现次数同样多的,以字 ...

  10. vue项目开发中遇到的几个问题

    1.使用elment或者mintUI库时,需要全局引入ui库的css文件:然后在修改自己样式时,需要将自己的css文件引入到main.js中才会生效,全局引用2.使用v-html展示dom字符串时,相 ...