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

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

头图

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

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

当前进度

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


[toc]

关键字: 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("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);}"
                                           "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);}");

        ui->pushButton_return->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);}"
                                             "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);}");

        ui->pushButton_multimedia->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);}");

        ui->pushButton_navigation->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);}");

        ui->pushButton_radio->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);}"
                                            "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);}");

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

        ui->pushButton_return->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);}"
                                             "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);}");

        ui->pushButton_multimedia->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);}");

        ui->pushButton_navigation->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);}");

        ui->pushButton_radio->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);}"
                                            "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);}");

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

        ui->pushButton_return->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);}"
                                             "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);}");

        ui->pushButton_multimedia->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);}");

        ui->pushButton_navigation->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);}");

        ui->pushButton_radio->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio.png);}"
                                            "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);}");

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

        ui->pushButton_return->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);}"
                                             "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);}");

        ui->pushButton_multimedia->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);}");

        ui->pushButton_navigation->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);}");

        ui->pushButton_radio->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);}"
                                            "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);}");

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

        ui->pushButton_return->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);}"
                                             "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);}");

        ui->pushButton_multimedia->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);}");

        ui->pushButton_navigation->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);}");

        ui->pushButton_radio->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);}"
                                            "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);}");

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

        ui->pushButton_return->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);}"
                                             "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);}");

        ui->pushButton_multimedia->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);}");

        ui->pushButton_navigation->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);}");

        ui->pushButton_radio->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);}"
                                            "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);}");

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

        ui->pushButton_return->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);}"
                                             "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);}");

        ui->pushButton_multimedia->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);}");

        ui->pushButton_navigation->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);}");

        ui->pushButton_radio->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);}"
                                            "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);}");

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

    {
        ui->pushButton_menu->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);}"
                                           "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);}");

        ui->pushButton_return->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);}"
                                             "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);}");

        ui->pushButton_multimedia->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);}");

        ui->pushButton_navigation->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);}");

        ui->pushButton_radio->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);}"
                                            "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);}");

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

        ui->pushButton_return->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);}"
                                             "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);}");

        ui->pushButton_multimedia->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);}");

        ui->pushButton_navigation->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);}");

        ui->pushButton_radio->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);}"
                                            "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);}");

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

        ui->pushButton_return->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);}"
                                             "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);}");

        ui->pushButton_multimedia->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);}");

        ui->pushButton_navigation->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);}"
                                                 "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);}");

        ui->pushButton_radio->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);}"
                                            "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);}");

        ui->pushButton_phone->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_2.png);}"
                                            "QPushButton:pressed{border-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("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu.png);}"
                                       "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/menu_1.png);}");

    ui->pushButton_return->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return.png);}"
                                         "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/return_1.png);}");

    ui->pushButton_multimedia->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_2.png);}"
                                             "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/multimedia_1.png);}");

    ui->pushButton_navigation->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_2.png);}"
                                             "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/navigation_1.png);}");

    ui->pushButton_radio->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_2.png);}"
                                        "QPushButton:pressed{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/radio_1.png);}");

    ui->pushButton_phone->setStyleSheet("QPushButton{border-image: url(:/Bottom/Resources/MultifunctionDisplay/Bottom/phone_2.png);}"
                                        "QPushButton:pressed{border-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);
    });
}

​ 这样就可以启动了。

image-20220427230026478

​ 今天就先更到这里。

第三阶段成果展示

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

[video(video-yznBr6e3-1648369267384)(type-bilibili)(url-https://player.bilibili.com/player.html?aid=679609061)(image-https://ucc.alicdn.com/images/user-upload-01/img_convert/4d157e1cb316b007a2cb9790cb2dbfde.png)(title-基于Qt的汽车仪表模拟 3.0)]

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

第二阶段成果展示

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

[video(video-2AqJ88TY-1645273728489)(type-bilibili)(url-https://player.bilibili.com/player.html?aid=594179292)(image-https://ucc.alicdn.com/images/user-upload-01/img_convert/e75563c3ce68bc980547dde8f6e265ba.png)(title-基于Qt的汽车仪表模拟 2.0)]

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

第一阶段成果展示

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

[video(video-ArCvRvBQ-1642664938100)(type-bilibili)(url-https://player.bilibili.com/player.html?aid=77197267)(image-https://ucc.alicdn.com/images/user-upload-01/img_convert/ccddd04e0cef191fd33d7f58d41adb24.png)(title-基于Qt的汽车仪表模拟 1.0))]

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


说明:

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

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

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

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

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

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


博客签名2021

相关文章
|
API 开发者
HarmonyOS学习路之开发篇—设备管理(控制类小器件)
控制类小器件指的是设备上的LED灯和振动器。其中,LED灯主要用作指示(如充电状态)、闪烁功能(如三色灯)等;振动器主要用于闹钟、开关机振动、来电振动等场景。
|
7月前
|
图形学
Unity Hololens2开发|(六)MRTK3子系统 DictationSubsystem(听写功能)
Unity Hololens2开发|(六)MRTK3子系统 DictationSubsystem(听写功能)
|
JavaScript 定位技术 API
HMI-51-【多媒体】搞地图 1
其实,说道搞地图,我也真不知道咋搞,完全没有搞过。看高德的`api`,基本都是基于`JS`,这个我更没有玩过了,所有,后面的内容深度和进度我不负责哈哈。
|
物联网 定位技术 开发工具
HMI-64-【多媒体】Ui全部制作完成
重点:这段时间公司项目换平台,在加上家里娃娃出生,是真的没有时间搞这个项目,这个项目先只能按下暂停键。不过庆幸的是资源文件全部都做完了,喜欢的小伙伴,可以联系我,继续搞下去。
HMI-53-【多媒体】音乐播放器 2
今天我们接着搞我们的音乐播放器,今天我把们昨天剩下的那些布局搞一搞,后面再实现细节,今天我们把下面的菜单和逻辑实现了,以及上次漏掉的右上角的子菜单按钮。
HMI-54-【多媒体】音乐播放器 3
今天我们接着搞音乐播放器,今天我们实现这个中心的音乐播放器。也就是这个歌曲信息,上一曲下一曲暂停,播放进度啥的。
HMI-55-【多媒体】音乐播放器 4
今天我们接着搞音乐播放器,今天主要实现音乐播放器的播放音频功能
HMI-52-【多媒体】音乐播放器 1
今天我们搞音乐播放器,哎嗨,这个东西要是往细碎了搞,事情还真不少,今天就先努力实现面上的内容。
HMI-56-【多媒体】音乐播放器 5
上一篇中实现了音乐播放的后台线程,夜里睡觉也没有睡踏实,总是感觉不合适,所以今天还是决定重新搞一下。
利用鸿蒙系统硬件实现音乐播放功能之优秀
利用鸿蒙系统硬件实现音乐播放功能之优秀 今天主要和大家聊一聊,如何使用鸿蒙系统中的脉冲宽度调制,利用微处理器的数字输出来对模拟电路进行控制的一种方法​。
219 0
利用鸿蒙系统硬件实现音乐播放功能之优秀