Qt Qwdget 汽车仪表知识点拆解3 进度条编写
先贴上效果图,注意,没有写逻辑,都是乱动的
这篇我来说说左侧的这个进度条的实现原理,其实更简单,哈哈哈
有一个大的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;
}
}
这样,就可以了
Qt Qwdget 汽车仪表知识点拆解3 进度条编写的更多相关文章
- Qt Qwdget 汽车仪表知识点拆解4 另类进度条实现
先贴上效果图,注意,没有写逻辑,都是乱动的 注意看一下,右面的这两个进度条,有瑕疵,就是我没有把图片处理干净,这里犹豫我不知道这个具体的弧度,也没法绘制,就偷懒了 现在上面放一个UI,把两个进度条抠空 ...
- Qt Qwdget 汽车仪表知识点拆解6 自定义控件
先贴上效果图,注意,没有写逻辑,都是乱动的 这里说一下控件自定义 图中标出的部分都是自定义的控件 这里如果我们有批量类似的功能,就可以使用自定义控件的方式,这里我已下面的自定义控件说一下,上面的在上一 ...
- Qt Qwdget 汽车仪表知识点拆解2 图像放大
先贴上效果图,注意,没有写逻辑,都是乱动的 这里讲下 这个小汽车的进入过程,其实这个说白了就没有技术含量了,本来应该趁着这个机会学习一下Qt的动画机制,不过随机一想,这个自己写也累不到那里去 下面说下 ...
- Qt Qwdget 汽车仪表知识点拆解8 淡入效果
先贴上效果图,注意,没有写逻辑,都是乱动的 看下面的开始,开始的时候有一个带入的效果,这里有一个坑, 网上大部分都是调用下面这个函数 setWindowOpacity(); 但是,你会发现,在你的子窗 ...
- Qt Qwdget 汽车仪表知识点拆解7 图像绘制,旋转
先贴上效果图,注意,没有写逻辑,都是乱动的 看下最中心的指针旋转,这里使用的QPainter的绘制函数 要显示复杂的效果,需要分层 void Widget::draw_number_pointer() ...
- Qt Qwdget 汽车仪表知识点拆解5 标题栏图标闪烁
先贴上效果图,注意,没有写逻辑,都是乱动的 看下最上面的部分,有一些仪表图标在闪烁,如果一个一个写,也是可以实现的,不过感觉要累死的节奏 这里我写了一个我自己的Label,完了把把这些QLabel提升 ...
- Qt Qwdget 汽车仪表知识点拆解1 速度表示
先贴上效果图,注意,没有写逻辑,所以这些都是乱动的 这里线主要说一下中间显示速度的显示制作的方式,在这里,自己专门写了一个数字的仪表 考虑的一般的汽车是没有办法把瞬时速度提升到四位数的,所以我这里就放 ...
- MFC控件编程进度条编写
MFC控件编程进度条编写 一丶进度条编程需要用到的方法 进度条MFC已经帮我们封装好类了. 叫做 CProgressCtrl 进度条编程也很简单. 封装的方法也就那个那几个. GetPos() 获 ...
- Qt之模型/视图(自定义进度条)
简述 在之前的章节中分享过关于QHeaderView表头排序.添加复选框等内容,相信大家模型/视图.自定义风格有了一定的了解,下面我们来分享一个更常用的内容-自定义进度条. 实现方式: 从QAbstr ...
随机推荐
- 活到老学到老:iOS开发中的基础知识(一)
本文参考 标哥的博客:宝库iOS开发笔试题 进行学习整理.与其说是看面试题,不如说是对自己知识的巩固.工欲善其事必先利其器,基础知识不牢固可能会导致编程中的一些注意不到的问题.总之一句话:活到老,学到 ...
- maven常用依赖总结
Apache工具组件 <!-- 字符串处理 --> <dependency> <groupId>org.apache.commons</groupId> ...
- xml或其他附件下载到客户端
//xml Document document=DocumentHelper.createDocument(); Element root=document.addElement("root ...
- js CheckBox只读
checkbox没有readOnly属性 所以我们要设置CHeckbox是只读的话就要设置其onclick方法并返回false checkbox.onclick=function(){return f ...
- 数据库——MySQL——多表查询
这里多表,为了方便我只建了两张表,更复杂的表间也就是这些东西,就是复杂程度不一样. 数据源准备 建立一个学生表,和一个班级表 # 建立学生表 create table student( id int ...
- 打造开源GIS方案
现在GIS用途较多,最近要有所接触,所以决定自己打造一个已经又的方案.均以Java作为开发 二位地图:客户端:geotools,swing,geoserver; web:openlayer,geose ...
- Ionic的项目结构(angluar js)
Hybird HTML5 App(移动应用开发)之3.Ionic的项目结构 前面使用命令ionic start myapp下载了默认的Ionic应用程序,下面我们打开应用程序项目,来分析一下Ionic ...
- js关于if(''==0)
在js当中,如下注意 if(''==0){ alert("空字符代表false"); } 空字符串代表false 0代表false false==false 结果就为true了
- swiper不能手指滑动翻页的解决办法
/*当swiper中的slide的里面放入长度在手机上不能滑动的时候 放入这段代码就可以了*/ var startScroll, touchStart, touchCurrent; ...
- CentOS7 64位下 MySQL5.7的安装与配置(YUM)
趁着11.11的时候在阿里云上弄了一云服务ECS(作为自己的节日礼物 > _ <) ,系统为CentOS的,打算弄一个人博客之类的,这些天正在备案当中(不知得多久). 忙里偷闲,在中午休息 ...