HMI-38-【节能模式】中心仪表mini仪表速度表实现

简介: 今天我们来做中心仪表的mini仪表中的车速表,就是三个数字显示,数字素材因为我的艺术家给我设计的时候,偷懒了,没有用下图中的字体,还是沿用了运动和舒适模式中的字体,咱们就将就的用吧,没有办法呀,咱也不会搞美术呀。

HMI-38-【节能模式】中心仪表mini仪表速度表实现

​ 今天我们来做中心仪表的mini仪表中的车速表,就是三个数字显示,数字素材因为我的艺术家给我设计的时候,偷懒了,没有用下图中的字体,还是沿用了运动和舒适模式中的字体,咱们就将就的用吧,没有办法呀,咱也不会搞美术呀。

当前进度

​ 当前进度如下,今天在原来的基础上,实现了中心mini仪表的车速模拟,顺带手把限速表也做了,就是一个背景加上一个数字。


[TOC]

关键字: HIMIQPainterQtdrawPixmapeco

Mini仪表转速表实现

​ 转速表实现其实非常加单,完全可以借鉴舒适模式中的实现模式,这次我对数字素材做了加工,更加简单的,简单粗暴换图片即可,代码如下:

void MDE_CenterMini::setCarSpeed(int speed)
{
    int one = speed % 10;
    int ten = speed /10 % 10;;
    int hunderd = speed /100;

    if(speed <10)
    {
        ui->label_one->setGeometry(150,140,120,86);
        ui->label_one->show();
        ui->label_ten->hide();
        ui->label_hundred->hide();
        switch (one) {
        default:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/0.png);}");
            break;
        }
        case 0:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/0.png);}");
            break;
        }
        case 1:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/1.png);}");
            break;
        }
        case 2:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/2.png);}");
            break;
        }
        case 3:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/3.png);}");
            break;
        }
        case 4:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/4.png);}");
            break;
        }
        case 5:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/5.png);}");
            break;
        }
        case 6:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/6.png);}");
            break;
        }
        case 7:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/7.png);}");
            break;
        }
        case 8:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/8.png);}");
            break;
        }
        case 9:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/9.png);}");
            break;
        }
        }
    }
    else if(speed >= 10 && speed < 100)
    {
        ui->label_one->setGeometry(200,140,120,86);
        ui->label_ten->setGeometry(100,140,120,86);
        ui->label_one->show();
        ui->label_ten->show();
        ui->label_hundred->hide();
        switch (one) {
        default:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/0.png);}");
            break;
        }
        case 0:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/0.png);}");
            break;
        }
        case 1:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/1.png);}");
            break;
        }
        case 2:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/2.png);}");
            break;
        }
        case 3:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/3.png);}");
            break;
        }
        case 4:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/4.png);}");
            break;
        }
        case 5:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/5.png);}");
            break;
        }
        case 6:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/6.png);}");
            break;
        }
        case 7:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/7.png);}");
            break;
        }
        case 8:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/8.png);}");
            break;
        }
        case 9:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/9.png);}");
            break;
        }
        }
        switch (ten) {
        default:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/0.png);}");
            break;
        }
        case 0:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/0.png);}");
            break;
        }
        case 1:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/1.png);}");
            break;
        }
        case 2:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/2.png);}");
            break;
        }
        case 3:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/3.png);}");
            break;
        }
        case 4:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/4.png);}");
            break;
        }
        case 5:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/5.png);}");
            break;
        }
        case 6:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/6.png);}");
            break;
        }
        case 7:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/7.png);}");
            break;
        }
        case 8:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/8.png);}");
            break;
        }
        case 9:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/9.png);}");
            break;
        }
        }
    }
    else if(speed >= 100 && speed < 1000)
    {
        ui->label_one->setGeometry(250,140,120,86);
        ui->label_ten->setGeometry(150,140,120,86);
        ui->label_hundred->setGeometry(50,140,120,86);
        ui->label_one->show();
        ui->label_ten->show();
        ui->label_hundred->show();
        switch (one) {
        default:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/0.png);}");
            break;
        }
        case 0:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/0.png);}");
            break;
        }
        case 1:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/1.png);}");
            break;
        }
        case 2:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/2.png);}");
            break;
        }
        case 3:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/3.png);}");
            break;
        }
        case 4:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/4.png);}");
            break;
        }
        case 5:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/5.png);}");
            break;
        }
        case 6:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/6.png);}");
            break;
        }
        case 7:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/7.png);}");
            break;
        }
        case 8:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/8.png);}");
            break;
        }
        case 9:
        {
            ui->label_one->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/9.png);}");
            break;
        }
        }
        switch (ten) {
        default:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/0.png);}");
            break;
        }
        case 0:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/0.png);}");
            break;
        }
        case 1:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/1.png);}");
            break;
        }
        case 2:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/2.png);}");
            break;
        }
        case 3:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/3.png);}");
            break;
        }
        case 4:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/4.png);}");
            break;
        }
        case 5:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/5.png);}");
            break;
        }
        case 6:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/6.png);}");
            break;
        }
        case 7:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/7.png);}");
            break;
        }
        case 8:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/8.png);}");
            break;
        }
        case 9:
        {
            ui->label_ten->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/9.png);}");
            break;
        }
        }
        switch (hunderd) {
        default:
        {
            ui->label_hundred->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/0.png);}");
            break;
        }
        case 0:
        {
            ui->label_hundred->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/0.png);}");
            break;
        }
        case 1:
        {
            ui->label_hundred->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/1.png);}");
            break;
        }
        case 2:
        {
            ui->label_hundred->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/2.png);}");
            break;
        }
        case 3:
        {
            ui->label_hundred->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/3.png);}");
            break;
        }
        case 4:
        {
            ui->label_hundred->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/4.png);}");
            break;
        }
        case 5:
        {
            ui->label_hundred->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/5.png);}");
            break;
        }
        case 6:
        {
            ui->label_hundred->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/6.png);}");
            break;
        }
        case 7:
        {
            ui->label_hundred->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/7.png);}");
            break;
        }
        case 8:
        {
            ui->label_hundred->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/8.png);}");
            break;
        }
        case 9:
        {
            ui->label_hundred->setStyleSheet("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/9.png);}");
            break;
        }
        }
    }
}

这个代码是又臭又长,不过到时好理解哈,下面我给他升级一下(也不难懂哈):

void MDE_CenterMini::setCarSpeed(int speed)
{
    int one = speed % 10;
    int ten = speed /10 % 10;;
    int hunderd = speed /100;

    if(speed <10)
    {
        ui->label_one->setGeometry(150,140,120,86);
        ui->label_one->show();
        ui->label_ten->hide();
        ui->label_hundred->hide();
        ui->label_one->setStyleSheet(QString("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/%1.png);}").arg(one));
    }
    else if(speed >= 10 && speed < 100)
    {
        ui->label_one->setGeometry(200,140,120,86);
        ui->label_ten->setGeometry(100,140,120,86);
        ui->label_one->show();
        ui->label_ten->show();
        ui->label_hundred->hide();
        ui->label_one->setStyleSheet(QString("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/%1.png);}").arg(one));
        ui->label_ten->setStyleSheet(QString("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/%1.png);}").arg(ten));

    }
    else if(speed >= 100 && speed < 1000)
    {
        ui->label_one->setGeometry(250,140,120,86);
        ui->label_ten->setGeometry(150,140,120,86);
        ui->label_hundred->setGeometry(50,140,120,86);
        ui->label_one->show();
        ui->label_ten->show();
        ui->label_hundred->show();
        ui->label_one->setStyleSheet(QString("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/%1.png);}").arg(one));
        ui->label_ten->setStyleSheet(QString("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/%1.png);}").arg(ten));
        ui->label_hundred->setStyleSheet(QString("QLabel{border-image:url(:/Economic/Resources/MeterDisplay/Economic/Number/%1.png);}").arg(hunderd));
    }
}

限速表实现

​ 限速表实现就更简单了,就是两个label,一个用来做背景,一个用来做数字显示,直接上接口实现:

void MDE_Center::setSpeedLimit(int speed, bool visable)
{
    if(visable)
    {
        ui->label_speedlimit_number->show();
        ui->label_speedlimit_back->show();
        ui->label_speedlimit_number->setText(QString::number(speed,10));
    }
    else
    {
        ui->label_speedlimit_number->hide();
        ui->label_speedlimit_back->hide();
        ui->label_speedlimit_number->setText(QString::number(speed,10));
    }
}

说明:

本项目中所使借鉴原型来自:[吉利] 博瑞GE | 仪表HMI设计吉利汽车HMI项目

设计图的所有权和解释权都归吉利汽车所有。

本项目所有资源文件均有打不死的小海复刻制作。

本项目代码暂时不会开源,有需要的源码的可与我联系,左上角二维码加微信。

本项目仅限学习交流、禁止商业使用。


博客签名2021

相关文章
电路板设计中射频反馈线的优化
最近,我们的信号完整性小组 要求重新设计现有的5千兆赫接地共面波导射频反馈线,以提高客户板上Wi-Fi子系统的性能。测量结果表明,给水线阻抗的阻抗约为38欧姆。
|
6月前
|
存储 传感器 编解码
LabVIEW风力涡轮机的雷电流测量系统中集成高速摄像机
LabVIEW风力涡轮机的雷电流测量系统中集成高速摄像机
44 1
HMI-37-【节能模式】中心仪表实现
节能模式下,做难做的就是中心仪表了,其他两个都很简单了。那么今天就把这个给实现了。
HMI-37-【节能模式】中心仪表实现
HMI-39-【节能模式】实现中心仪表转速表自检及左右仪表布局
昨天我们把中心仪表的迷你仪表应写出来了,并且实现了速度表的显示,今天我们来搞一下这个中心仪表的自检,也就是转速表的自检。
HMI-39-【节能模式】实现中心仪表转速表自检及左右仪表布局
HMI-29-【运动模式】转速表实现及中心油耗仪表实现
今天我要搞得就是中心的这个表,指针的是转速表 中心显示的油耗表。
HMI-29-【运动模式】转速表实现及中心油耗仪表实现
HMI-35-【运动模式】实现速度表和转速表自检
今天咱们给速度表和转速表增加一个自检功能, 就是从小走大最大再回到最小。用到的和上篇一样,也是有一个自己写的定时器。
便携式钻孔测斜仪测区如何设置
完成当前测区的添加(新建) 、删除操作。WIN5/612 便携式钻孔测斜仪的数据以区域进行划分,一个区域代表一个地理区域,亦或是一个工程、一个工地。设备默认保存最近一次测量时使用测区名称,对同一测区进行测量时无需再次选择设置。若需更换当前测区名称,请按照以下步骤操作。
便携式钻孔测斜仪测区如何设置
|
数据管理 数据库
便携式钻孔测斜仪软件运行状态
设备启动后,自动进入测斜仪程序主界面(若设置了程序自动启动),主界面见图 5.1。若未设置程序自动启动,则可通过双击系统桌面上的测量【APP】程序快捷方式,进入软件。
便携式钻孔测斜仪软件运行状态
|
传感器 存储
手持VH501TC多功能混合传感器信号采集读数仪使用方法
电池仓位于设备背面下半部分, 仅当使用 5 号电池供电时需要操作电池仓,锂电池供电的设备无需操作电池仓。默认情况下,电池仓盖处于锁定状态无法直接打开,在需要安装或者更换电池时,应将水平拨动开关推至解锁侧,在电池安装完成后必须将开关推至锁定侧。注意:在安装电池时必须按照仓内+/-符号对应电池的正/负极,错误的安装极性会永久性损坏设备。
手持VH501TC多功能混合传感器信号采集读数仪使用方法
|
传感器 存储 物联网
多功能手持读数仪振弦混合信号采集仪的版本区别
VH501TC手持采集读数仪,设备是专用的多类型传感器手持式读数仪,主测传感类型为单弦式振弦传感器,辅测传感类型为电压、电流传感。采用 32 位 ARM 处理器和大尺寸全彩屏、阵列按键设计,彩屏,不受阳光影响,清楚明了。操作界面简单友好,各项数据全屏显示,如振弦频率,频模,温度,采集质量,时间显示,电压电流,激励电压,激励方法,温度传感器及剩余电量。指示灯显示说明运行情况,DB9和通讯航空接口连接稳固,后盖更换电池方便。按键回弹手感好,整机好握持,单手操作,操作舒适,在完成快速测读的同时还具备很好的操控体验。外壳坚固耐用,方便携带能在不同工况场景下使用。
多功能手持读数仪振弦混合信号采集仪的版本区别