Qt widget使用QML自定义导航栏
具体方法:
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自定义导航栏的更多相关文章
- 分别用ToolBar和自定义导航栏实现沉浸式状态栏
一.ToolBar 1.在build.gradle中添加依赖,例如: compile 'com.android.support:appcompat-v7:23.4.0' 2.去掉应用的ActionBa ...
- swift 自定义导航栏颜色
func setNavigationApperance(){ //自定义导航栏颜色 [self.navigationController?.navigationBar.barTintColor = U ...
- ios7以上自定义导航栏标题的字体大小及颜色的方法
自定义导航栏的字体和颜色,只需要自定义一个lable,然后将lable添加到导航栏的titleview中就可以了 代码如下 UILabel *label = [[UILabel alloc] init ...
- iOS 自定义导航栏笔记
一.UINavigationBar的结构 导航栏几乎是每个页面都会碰到的问题,一般两种处理方式:1.隐藏掉不显示 2.自定义 1. 添加导航栏 TestViewController * mainVC ...
- 微信小程序自定义导航栏
微信小程序需要自定义导航栏,特别是左上角的自定义设置,可以设置返回按钮,菜单按钮,配置如下: 1.在app.json的window属性中增加: navigationStyle:custom 顶部导航栏 ...
- iOS:自定义导航栏,随着tableView滚动显示和隐藏
自定义导航栏,随着tableView滚动显示和隐藏 一.介绍 自定义导航栏是APP中很常用的一个功能,通过自定义可以灵活的实现动画隐藏和显示效果.虽然处理系统的导航栏也可以实现,但是这个是有弊端的,因 ...
- 微信小程序 - 自定义导航栏(提示)
点击下载: 自定义导航栏示例
- 微信小程序——自定义导航栏
微信头部导航栏可能通过json配置: 但是有时候我们项目需求可能需要自定义头部导航栏,如下图所示: 现在具体说一下实现步骤及方法: 步骤: 1.在 app.json 里面把 "navigat ...
- 微信小程序-如何自定义导航栏(navigationStyle)?
小程序是越来越开放了,微信版本 6.6.0可以自定义导航? 先了解下app.json中window配置navigationStyle属性,即导航栏样式,仅支持 default/custom.custo ...
随机推荐
- 神经网络(10)--有助于对神经网络Backpropagation算法的理解
为了更好的理解backpropagation,先来了解一下forward propagation的内部 我们在forward propagation中计算Z1(3)的方法与在back propagat ...
- vue-cli搭建项目的坑
使用vue-cli生成的项目默认没有 --open,所以npm run dev运行项目后,不会自动打开浏览器, 需要手动添加--open,反之,如果不需要自动打开浏览器,删除就好了
- go函数类型的使用
Go函数类型的使用 type myfunc func() string // 声明函数变量 func main() { fn := func() string { return "bbb&q ...
- C 语言程序设计
C 语言数据类型: 整数: char(也是字符型) short int long 浮点型: float double 指针 自定义类型 输入输出格式化: int ->%d long ->% ...
- Validation参数验证
在SpringBoot项目中其实已经默认引入了,如果不是sprongBoot项目则需要导入Maven <dependency> <groupId>org.hibernate.v ...
- .NetCore WebApi结构及前端访问方式
.NetCore WebApi结构及前端访问方式(Ajax方式,fetch方式,axios方式) //访问的地址api/控制器名称/方法名称;action一般会省略 [Route("api/ ...
- 洛谷 AT2434 JOI 公園 (JOI Park) 题解
人生第一次AC黑题,我太感动了. 每日一题 day31 打卡 Analysis 先跑遍DJ,求出1到 i的最短路.得到每个点到 1号点的距离后,从小到大排序一遍,这时便可以枚举每个点到 1号点的距离修 ...
- WebAPI学习
WebAPI概述 今天的web计算平台包含了广泛的功能,其中的大部分均可以通过API(应用程序编程接口)访问. web平台归为6个基本设施,都会用到webapi,包括存储服务.消息服务.计算服务.信息 ...
- mybatis-helper
mybatis-helper 在mapper层可以跳转到sql xml中 只需要在idea plugin中搜索即可.
- python生成词云
上代码: # -*- coding: utf-8 -*- # @Time : 19-1-10 上午10:27 # @Author : Felix Wang import jieba # pip ins ...