Qt Qwdget 汽车仪表知识点拆解3 进度条编写
2024-10-15 13:22:22
先贴上效果图,注意,没有写逻辑,都是乱动的
这篇我来说说左侧的这个进度条的实现原理,其实更简单,哈哈哈
有一个大的widget,根据素材,我放了10个label
剩下的就是写一个函数,根据数据的不同,实时控制这10个label的显示,
实现代码
void Widget::show_Lline(int num)
{ switch (num) {
case 0:
{
ui->label_lline_1->hide();
ui->label_lline_2->hide();
ui->label_lline_3->hide();
ui->label_lline_4->hide();
ui->label_lline_5->hide();
ui->label_lline_6->hide();
ui->label_lline_7->hide();
ui->label_lline_8->hide();
ui->label_lline_9->hide();
ui->label_lline_10->hide();
break;
}
case 1:
{
ui->label_lline_1->show();
ui->label_lline_2->hide();
ui->label_lline_3->hide();
ui->label_lline_4->hide();
ui->label_lline_5->hide();
ui->label_lline_6->hide();
ui->label_lline_7->hide();
ui->label_lline_8->hide();
ui->label_lline_9->hide();
ui->label_lline_10->hide();
break;
}
case 2:
{
ui->label_lline_1->show();
ui->label_lline_2->show();
ui->label_lline_3->hide();
ui->label_lline_4->hide();
ui->label_lline_5->hide();
ui->label_lline_6->hide();
ui->label_lline_7->hide();
ui->label_lline_8->hide();
ui->label_lline_9->hide();
ui->label_lline_10->hide();
break;
}
case 3:
{
ui->label_lline_1->show();
ui->label_lline_2->show();
ui->label_lline_3->show();
ui->label_lline_4->hide();
ui->label_lline_5->hide();
ui->label_lline_6->hide();
ui->label_lline_7->hide();
ui->label_lline_8->hide();
ui->label_lline_9->hide();
ui->label_lline_10->hide();
break;
}
case 4:
{
ui->label_lline_1->show();
ui->label_lline_2->show();
ui->label_lline_3->show();
ui->label_lline_4->show();
ui->label_lline_5->hide();
ui->label_lline_6->hide();
ui->label_lline_7->hide();
ui->label_lline_8->hide();
ui->label_lline_9->hide();
ui->label_lline_10->hide();
break;
}
case 5:
{
ui->label_lline_1->show();
ui->label_lline_2->show();
ui->label_lline_3->show();
ui->label_lline_4->show();
ui->label_lline_5->show();
ui->label_lline_6->hide();
ui->label_lline_7->hide();
ui->label_lline_8->hide();
ui->label_lline_9->hide();
ui->label_lline_10->hide();
break;
}
case 6:
{
ui->label_lline_1->show();
ui->label_lline_2->show();
ui->label_lline_3->show();
ui->label_lline_4->show();
ui->label_lline_5->show();
ui->label_lline_6->show();
ui->label_lline_7->hide();
ui->label_lline_8->hide();
ui->label_lline_9->hide();
ui->label_lline_10->hide();
break;
}
case 7:
{
ui->label_lline_1->show();
ui->label_lline_2->show();
ui->label_lline_3->show();
ui->label_lline_4->show();
ui->label_lline_5->show();
ui->label_lline_6->show();
ui->label_lline_7->show();
ui->label_lline_8->hide();
ui->label_lline_9->hide();
ui->label_lline_10->hide();
break;
}
case 8:
{
ui->label_lline_1->show();
ui->label_lline_2->show();
ui->label_lline_3->show();
ui->label_lline_4->show();
ui->label_lline_5->show();
ui->label_lline_6->show();
ui->label_lline_7->show();
ui->label_lline_8->show();
ui->label_lline_9->hide();
ui->label_lline_10->hide();
break;
}
case 9:
{
ui->label_lline_1->show();
ui->label_lline_2->show();
ui->label_lline_3->show();
ui->label_lline_4->show();
ui->label_lline_5->show();
ui->label_lline_6->show();
ui->label_lline_7->show();
ui->label_lline_8->show();
ui->label_lline_9->show();
ui->label_lline_10->hide();
break;
}
case 10:
{
ui->label_lline_1->show();
ui->label_lline_2->show();
ui->label_lline_3->show();
ui->label_lline_4->show();
ui->label_lline_5->show();
ui->label_lline_6->show();
ui->label_lline_7->show();
ui->label_lline_8->show();
ui->label_lline_9->show();
ui->label_lline_10->show();
break;
}
default:
break;
}
}
这样,就可以了
最新文章
- 《Continuous Delivery》 Notes 2: Configuration Management
- HDU4550+贪心
- codeforces 711B B. Chris and Magic Square(水题)
- iftop
- http://blog.csdn.net/foreverling/article/details/51385128
- 基于WebForm+EasyUI的业务管理系统形成之旅 -- 构建Web界面(Ⅴ)
- @Index用法——javax.persistence.Index
- 玩了一下SDN:MININET+FLOODLIGHT,感觉这确实是一个趋势啊
- [.NET] 《C# 高效编程》(一) - C# 语言习惯
- Node.js_express_服务器渲染页面 ejs
- JS_单个或多个文件上传_不支持单独修改
- AJAX请求返回HTTP 400 错误 - 请求无效 (Bad request)
- Unity-使用面向对象的思想
- PHP中使用CURL实现GET和POST请求(转载)
- [developmemt][dpdk] dpdk优化(转)
- 多线程——interrupt方法
- input 原生上传文件(type = file)
- CSS控制Span强制换行亲测
- Webpack vs Gulp(转载)
- MFC—— AfxMessageBox
热门文章
- 论坛数据转换discuz论坛?
- linux命令进阶及和windows进行文件传输的所有方式
- Spring知识点总结(三)之Spring DI
- PL/SQL 用户自定义子类型
- Invalid default value for prop ";value";: Props with type Object/Array must use a factory function to return the default value.(props default 数组/对象的默认值应当由一个工厂函数返回)
- ABAP术语-IAC (Internet Application Components)
- (四)、python 集合与格式化
- 【c学习-10】
- ECSHOP和SHOPEX快递单号查询德邦插件V8.6专版
- MIP组件开发 自定义js组件开发步骤