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 ...
随机推荐
- N皇后问题代码
/*.h*/ #ifndef _NQUEEN_H #define _NQUEEN_H #include<iostream> #include<vector> #include& ...
- python中类的函数中的self
Python类中的self到底是干啥的 Python编写类的时候,每个函数参数第一个参数都是self,一开始我不管它到底是干嘛的,只知道必须要写上.后来对Python渐渐熟悉了一点,再回头看self的 ...
- python - django (ORM常用字段)
# """ python manage.py makemigrations # 更新操作 python manage.py migrate # 转换sql语句到数据库 1 ...
- 010——MATLAB运行错误跳到下一个循环
(一)MATLAB运行错误跳到下一个循环 :%文件的个数 try %运行的程序放到这里 catch continue%假如上面的没法执行则执行continue,到下个循环 end
- learning java ProcessHandle 获取进程相当信息
Process p = rt.exec("notepad.exe"); ProcessHandle ph = p.toHandle(); System.out.println(&q ...
- 表述数据的手段——json
一.JSON 语法规则 在 JS 语言中,一切都是对象.因此,任何支持的类型都可以通过 JSON 来表示,例如字符串.数字.对象.数组等.但是对象和数组是比较特殊且常用的两种类型: 对象表示为键值对 ...
- Nginx 安装配置【必须把文件到放到机器上】
[必须把所有下载的gz文件到放到机器上:编译] 1.安装nginx之前的编译软件 yum -y install make zlib zlib-devel gcc-c++ libtool openss ...
- php之简单socket编程
一.什么是套接字 源IP地址和目的IP地址以及源端口号和目的端口号的组合称为套接字.其用于标识客户端请求的服务器和服务. 二.php套接字实例 服务端代码:socket.php <?php er ...
- Java中判断数组是否为空
一维数组// 一维数组: int[] arrayif(array == null || array.length == 0) return true; 二维数组//二维数组: int[][] a ...
- git图形化统计工具 - windows下gitstats的安装和使用
gitstats 是一款git历史统计工具,可以生成定量的统计数据,并以html图表的形式展示.统计文件包括文件数量.代码量.提交量.作者信息.每天活跃度.每周活跃度.每月活跃度以及提交数排名等等,信 ...