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 ...
随机推荐
- keras模块学习之泛型模型学习笔记
本笔记由博客园-圆柱模板 博主整理笔记发布,转载需注明,谢谢合作! Keras泛型模型接口是: 用户定义多输出模型.非循环有向模型或具有共享层的模型等复杂模型的途径 适用于实现:全连接网络和多输入 ...
- Windows窗体控件实现内容拖放(DragDrop)功能
一.将控件内容拖到其他控件 在开发过程中,经常会有这样的要求,拖动一个控件的数据到另外一个控件中.例如将其中一个ListBox中的数据拖到另一个ListBox中.或者将DataGridView中的数据 ...
- Tiny C Compiler简介-wiki
Tiny C Compiler(缩写为TCC.tCc或TinyCC)是一个用于x86(16/32位)或x86-64(64位)系统的C编译器,开发者为Fabrice Bellard.软件是设计用于低级计 ...
- 获取当前主题颜色 Flutter
通过context获取当前主题颜色 Theme.of(context).accentColor
- Linux https认证原理
HTTPS在传输的过程中会涉及到三个密钥:服务器端的公钥和私钥,用来进行非对称加密客户端生成的随机密钥,用来进行对称加密一个HTTPS请求实际上包含了两次HTTP传输,可以细分为8步.1.客户端向服务 ...
- LibreOJ #524. 「LibreOJ β Round #4」游戏
二次联通门 : LibreOJ #524. 「LibreOJ β Round #4」游戏 /* LibreOJ #524. 「LibreOJ β Round #4」游戏 找找规律就会发现.. 当有X的 ...
- 如何在Processing中用鼠标获取RGB颜色数值
要做一个抠图应用,所以随手做了个鼠标取色,代码如下: void mousePressed(){ int imgC = get(mouseX,mouseY); int R = (imgC >> ...
- 自主设计BootLoader框架笔记一栏
- Bat 复制本地文件到共享目录
@echo off title "copy UI" net use \\172.16.104.93\心电图 "password" /user:"adm ...
- java使用freemark生成word/pdf
目录 一. 背景 二.实现的技术选型以及遇到的坑 三.最终的效果 2.1 .doc word效果展示 2.1 .docx word效果展示 2.2 docx word转pdf效果展示 三.准备工作及代 ...