HMI-58-多媒体重构底部菜单

Posted DreamLife.

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HMI-58-多媒体重构底部菜单相关的知识,希望对你有一定的参考价值。

HMI-58-【多媒体】重构底部菜单

​ 今天的这个没有新的内容,就是计划重新构建下底部菜单,开始是在每个界面里面都做了底部菜单,开始我以为每个界面都不一样,和面我研究了一下发现,每个界面的底部菜单都是一样的呀,那我们就好所了,开始重构。把底部菜单移到他的父页面中。

当前进度

​ 今天主要内容就是重构了底部菜单。效果和原来基本一致。只不过现在不用一个一个页面的重复实现了,开始一直以为认为每个页面对应的底部菜单不一样,现在看来基本是一样的,所以这里我就按照一样处理了。


文章目录

关键字: HMIMultifunctionQtQMediaPlayerMusic

Bottom菜单实现

​ 因为这个版本的代码里面我感觉是挺讨巧的,使用了信号槽,和菜单功能对应起来了,所以这里直接贴上两个的的代码。

头文件

#ifndef MFD_BOTTOM_H
#define MFD_BOTTOM_H

#include <QWidget>
#include "MultifunctionDisplay/MFD_MenuDisplay/mfd_menudisplay.h"
namespace Ui 
class MFD_Bottom;


class MFD_Bottom : public QWidget

    Q_OBJECT

public:
    explicit MFD_Bottom(QWidget *parent = nullptr);
    ~MFD_Bottom();
signals:

    void signal_menuIndex(int index);

    void signal_return();
public slots:

    void slot_MainFrameIndexChanged(int index);
private slots:
    void on_pushButton_menu_clicked();

    void on_pushButton_navigation_clicked();

    void on_pushButton_multimedia_clicked();

    void on_pushButton_radio_clicked();

    void on_pushButton_phone_clicked();

    void on_pushButton_return_clicked();

private:
    /**
     * @brief paintEvent
     * @param event
     * 重绘事件,用于绘制背景
     */
    void paintEvent(QPaintEvent* event);

    void initButton();
private:
    Ui::MFD_Bottom *ui;
;

#endif // MFD_BOTTOM_H

源文件

#include "mfd_bottom.h"
#include "ui_mfd_bottom.h"
#include <QPainter>


MFD_Bottom::MFD_Bottom(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MFD_Bottom)

    ui->setupUi(this);


MFD_Bottom::~MFD_Bottom()

    delete ui;


void MFD_Bottom::slot_MainFrameIndexChanged(int index)

    switch (index) 
    case MainType::menu:
        this->hide();
        break;
    case MainType::airConditioner:
    
        ui->pushButton_menu->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);"
                                           "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);");

        ui->pushButton_return->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);"
                                             "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);");

        ui->pushButton_multimedia->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);");

        ui->pushButton_navigation->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);");

        ui->pushButton_radio->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);");

        ui->pushButton_phone->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_1.png);");
        break;
    
    case MainType::drivingRecorder:
    
        ui->pushButton_menu->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);"
                                           "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);");

        ui->pushButton_return->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);"
                                             "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);");

        ui->pushButton_multimedia->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);");

        ui->pushButton_navigation->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);");

        ui->pushButton_radio->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);");

        ui->pushButton_phone->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_1.png);");
        break;
    
    case MainType::radio:
    
        ui->pushButton_menu->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);"
                                           "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);");

        ui->pushButton_return->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);"
                                             "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);");

        ui->pushButton_multimedia->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);");

        ui->pushButton_navigation->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);");

        ui->pushButton_radio->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);");

        ui->pushButton_phone->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_1.png);");
        break;
    
    case MainType::multimedia:
    
        ui->pushButton_menu->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);"
                                           "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);");

        ui->pushButton_return->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);"
                                             "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);");

        ui->pushButton_multimedia->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);");

        ui->pushButton_navigation->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);");

        ui->pushButton_radio->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);");

        ui->pushButton_phone->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_1.png);");
        break;
    
    case MainType::navigation:
    
        ui->pushButton_menu->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);"
                                           "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);");

        ui->pushButton_return->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);"
                                             "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);");

        ui->pushButton_multimedia->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);");

        ui->pushButton_navigation->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);");

        ui->pushButton_radio->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);");

        ui->pushButton_phone->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_1.png);");
        break;
    
    case MainType::phone:
    
        ui->pushButton_menu->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);"
                                           "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);");

        ui->pushButton_return->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);"
                                             "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);");

        ui->pushButton_multimedia->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);");

        ui->pushButton_navigation->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);");

        ui->pushButton_radio->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);");

        ui->pushButton_phone->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_1.png);");
        break;
    
    case MainType::m360Panorama:
    
        ui->pushButton_menu->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);"
                                           "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);");

        ui->pushButton_return->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);"
                                             "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);");

        ui->pushButton_multimedia->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);");

        ui->pushButton_navigation->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);");

        ui->pushButton_radio->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);");

        ui->pushButton_phone->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_1.png);");
        break;
    
    case MainType::mobileConnect:

    
        ui->pushButton_menu->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);"
                                           "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);");

        ui->pushButton_return->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);"
                                             "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);");

        ui->pushButton_multimedia->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);");

        ui->pushButton_navigation->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);");

        ui->pushButton_radio->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);");

        ui->pushButton_phone->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_1.png);");
        break;
    
    case MainType::internetofVehicles:
    
        ui->pushButton_menu->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);"
                                           "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);");

        ui->pushButton_return->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);"
                                             "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);");

        ui->pushButton_multimedia->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);");

        ui->pushButton_navigation->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);");

        ui->pushButton_radio->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);");

        ui->pushButton_phone->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_1.png);");
        break;
    
    case MainType::setUp:
    
        ui->pushButton_menu->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);"
                                           "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);");

        ui->pushButton_return->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);"
                                             "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);");

        ui->pushButton_multimedia->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);");

        ui->pushButton_navigation->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);"
                                                 "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);");

        ui->pushButton_radio->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);");

        ui->pushButton_phone->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_2.png);"
                                            "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_1.png);");
        break;
    
    default:
        break;
    


void MFD_Bottom::paintEvent(QPaintEvent *event)

    Q_UNUSED(event)
    QPainter painter;
    painter.begin(this);
    painter.drawPixmap(0,0,width(),height(), QPixmap(":/Bottom/Resources/MultifunctionDisplay/Bottom/mainback.png"));               // 绘制背景
    painter.end();


void MFD_Bottom::initButton()

    ui->pushButton_menu->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);"
                                       "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);");

    ui->pushButton_return->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);"
                                         "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);");

    ui->pushButton_multimedia->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);"
                                             "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);");

    ui->pushButton_navigation->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);"
                                             "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);");

    ui->pushButton_radio->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);"
                                        "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);");

    ui->pushButton_phone->setStyleSheet("QPushButtonborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_2.png);"
                                        "QPushButton:pressedborder-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_1.png);");



void MFD_Bottom::on_pushButton_menu_clicked()

    emit signal_menuIndex(MainType::menu);



void MFD_Bottom::on_pushButton_navigation_clicked()

    emit signal_menuIndex(MainType::navigation);



void MFD_Bottom::on_pushButton_multimedia_clicked()

    emit signal_menuIndex(MainType::multimedia);



void MFD_Bottom::on_pushButton_radio_clicked()

    emit signal_menuIndex(MainType::radio);



void MFD_Bottom::on_pushButton_phone_clicked()

    emit signal_menuIndex(MainType::phone);



void MFD_Bottom::on_pushButton_return_clicked()





逻辑控制

initBottom

​ 这个函数主要功能就是初始化底部菜单,这里有两个函数,一个是接受主界面索引改变时的信号,一个是发送按钮按下的信号,在对应到改变主界面的值。

void MultifunctionDisplay::initBottom()


    m_Bottom = new MFD_Bottom(this);
    connect(ui->tabWidget_mainFrame,&QTabWidget::currentChanged,m_Bottom,&MFD_Bottom::slot_MainFrameIndexChanged);
    connect(m_Bottom,&MFD_Bottom::signal_menuIndex,this,[=](int index)ui->tabWidget_mainFrame->setCurrentIndex(index););
    m_Bottom->setGeometry(0,940,1920,140);
    m_Bottom->hide();

bottomMenuShow

​ 这个函数就是控制控制底部菜单显示和隐藏的动画。

void MultifunctionDisplay::bottomMenuShow(bool temp)


    QPropertyAnimation* bottomShow = new QPropertyAnimation(m_Bottom,"geometry",this);

    if(temp)
    
        m_Bottom->show();
        bottomShow->setStartValue(QRect(0,1081,1920,140));
        bottomShow->setEndValue(QRect(0,940,1920,140));
        bottomShow->setDirection(QPropertyAnimation::Forward);
        bottomShow->setDuration(300);
        bottomShow->start();
    
    else
    
        bottomShow->setStartValue(QRect(0,940,1920,140));
        bottomShow->setEndValue(QRect(0,1081,1920,140));
        bottomShow->setDirection(QPropertyAnimation::Forward);
        bottomShow->setDuration(200);
        bottomShow->start();
    

启动Bottom菜单

​ 当我们通过菜单进入到子页面的时候,就需要打开底部菜单,所以这里在初始化菜单界面需要增加显示下方界面的代码

void MultifunctionDisplay::initMenuDisplay()

    QGridLayout* pg=new QGridLayout;
    pg->setMargin(0);
    pg->setSpacing(0);
    m_menuDisplay = new MFD_MenuDisplay(ui->tab_menu);
    pg->addWidget(m_menuDisplay);
    ui->tab_menu->setLayout(pg);
    connect(m_menuDisplay,&MFD_MenuDisplay::signal_menuIndex,this,[=](int index)
        bottomMenuShow();
        ui->tabWidget_mainFrame->setCurrentIndex(index);
    );

​ 这样就可以启动了。

​ 今天就先更到这里。

第三阶段成果展示

​ 目前已完成液晶仪表三种模式的初步显示,小模块后期根据精力更新了,主要还得找美术来搞资源,自己能力不够。暂未跟新计划。展示如下:

基于Qt的汽车仪表模拟 3.0

B站链接:https://www.bilibili.com/video/BV1WS4y137y1/

第二阶段成果展示

​ 目前以完成HUD界面及接口开发,液晶仪表舒适模式和运动模式的开发。展示如下:

基于Qt的汽车仪表模拟 2.0

B站链接:https://www.bilibili.com/video/BV1aq4y1t7H7/

第一阶段成果展示

​ 目前以完成HUD界面及接口开发,液晶仪表舒适模式开发。展示如下:

基于Qt的汽车仪表模拟 1.0)

B站链接:https://www.bilibili.com/video/BV1qJ411X7Gs/


说明:

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

多媒体部分是来自吉利博瑞2017旗舰版界面所有权和解释权都归吉利汽车所有。

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

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

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

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


创作打卡挑战赛 赢取流量/现金/CSDN周边激励大奖

以上是关于HMI-58-多媒体重构底部菜单的主要内容,如果未能解决你的问题,请参考以下文章

跨界造手机,以后买吉利汽车送吉利手机?

以编程方式膨胀底部导航视图菜单

Android 创建底部栏菜单

李书福造手机,图个吉利?

我应该使用媒体查询进行响应式设计吗?

如何在侧边菜单的底部快速添加一个按钮?