alin的学习之路:嵌入式课程设计总结(基于Linux的Qt版MP3播放器)

嵌入式课程设计总结(基于Linux的Qt版MP3播放器)

废话不多写直接上图上代码,其中有很多不规范的地方,希望大佬们指正。

1.课设题目

设计一个MP3播放器,要求:使用Linux下的madplay进行歌曲的播放,一共有三大项:

  1. Linux下字符界面实现Mp3播放器
  2. 将字符界面移植到ARM板上运行
  3. Qt图形化Mp3界面

在本次课程设计中我主要负责Qt图形化的设计开发。

2.设计思路

  1. 使用双向循环链表存放添加的歌曲
  2. 使用system("madplay xxx.mp3 &");进行歌曲的播放
  3. 调用的图片使用与.mp3文件同样的文件名,只是后缀不同,则操作字符串即可进行调用(这个思路有点low,验收时老师说应该用解析MP3文件的方法)
  4. 界面分为主界面和播放界面,每首歌的专辑图和播放背景都不同,在播放的时候切换图片,播放的同时展示歌词和正在播放的歌曲名
  5. 几个主要的按钮:播放,暂停,上一曲,下一曲,随机播放
  6. 添加歌曲后会在列表中展示,并计数
  7. 删除列表中的歌曲,若被删除的歌曲当前正在播放,则跳回主界面
  8. 错误操作弹窗提示错误,错误操作包括:重复添加歌曲,歌曲列表没有歌曲时点击播放歌曲

3.主界面展示

alin的学习之路:嵌入式课程设计总结(基于Linux的Qt版MP3播放器)_第1张图片

简单解析:

alin的学习之路:嵌入式课程设计总结(基于Linux的Qt版MP3播放器)_第2张图片

播放展示:


4.布局

  1. widget.ui

alin的学习之路:嵌入式课程设计总结(基于Linux的Qt版MP3播放器)_第3张图片
2. smallwidget.ui

alin的学习之路:嵌入式课程设计总结(基于Linux的Qt版MP3播放器)_第4张图片

5.控件的使用

  1. 按钮:QPushButton
  2. 歌词:TextEdit
  3. 歌词列表:ListWidget
  4. 正在播放:LineEdit
  5. 专辑图片:label
  6. 音量:SpinBox+horizontalSlider
  7. 小图标:label
  8. 标题文字:label
  9. 错误弹窗:QMessageBox

6.核心代码

  1. wiget.h
#ifndef WIDGET_H
#define WIDGET_H

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
    void on_pushbutton_click();
    QMainWindow *qmainwindow;

    bool AddNode(const char *songName,const char* path);
    void InitializeList();
    char *MoveNext();
    char *MovePrevious();
    void RemoveNode(QString s);


private slots:
    void on_pushButton_5_clicked();

    void on_listWidget_itemClicked(QListWidgetItem *item);

    //void on_pushButton_3_clicked();

    //void on_pushButton_4_clicked();

    void on_pushButton_2_clicked();
    //void keyPressEvent( QKeyEvent *k );

    void on_pushButton_6_clicked();

//    void on_mySlider_sliderReleased();

//    void on_mySlider_sliderMoved(int position);

private:
    Ui::Widget *ui;

};
#endif // WIDGET_H
  1. 双向列表
//Double director circle ListNode
struct Node
{
    char songName[512];
    struct Node *next;
    struct Node *prev;
    int flag;
    char path[1024];
};
typedef struct Node* List;
static List head ;
static List tail ;
static List current;

void Widget::InitializeList()
{
    head =(struct Node*)malloc(sizeof(struct Node));

    tail = head;

    head->next = tail;
    head->prev = tail;

    //current = head->next;
    songNum = 0;
}


bool Widget::AddNode(const char *songName, const char *path)
{

        List pnew;
        List scan = head;

        pnew = (struct Node*)malloc(sizeof(struct Node));//在堆上创建节点
        if(pnew == NULL)
        {
            printf("malloc create error\n");
            return false;
        }

        strcpy(pnew->path,path);
        strcpy(pnew->songName,songName);
        pnew->next = NULL;
        pnew->prev = NULL;
        pnew->flag = 0;

        //judge overlap
        while(scan->next != tail){
            if(!strcmp(pnew->songName,scan->next->songName))
            {
                qDebug() << "this song already exists" << endl;
                return false;
            }
            scan = scan->next;//找打链表尾
        }

        pnew->prev = scan;
        pnew->next = tail;
        scan->next = pnew;
        tail->prev = pnew;

        songNum++;

        if(songNum == 1)
            current = head->next;

        return true;

}


char* Widget::MoveNext()
{
    if(current->next != tail){
        current = current->next;
    }
    else
    {
        current = head->next;
    }
    printf("this song is playing   %s",current->songName);
    return current->path; //fullname
}


char* Widget:: MovePrevious()
{
    if(current->prev != head)
    {
        current = current->prev;

    }
    else
    {
        current = head->prev;

    }
     printf("this song is playing   %s\n",current->songName);
     return current->path;
}

void Widget::RemoveNode(QString s)
{
    while(current->songName != s)
    {
        current = current->next;
    }
    List temp = current;
    temp->next->prev = temp->prev;
    current->prev->next = current->next;

//    current->next->prev = current->prev;
}
  1. 播放键
//播放 pushButton_2
    connect(ui->pushButton_2,&QPushButton::clicked,this,[=](){
        //judge songList whether NULL
        if(songNum == 0)
        {
            QMessageBox::critical(this,"critical","no songs in songList");
            return ;
        }
        //"madplay /home/itcast/Desktop/1.mp3 &"
        // -s 0:0:01:11 set action time
        QString str =  "madplay "+buf+" &";

        const char* strChar = str.toLatin1();
        QString RealfileName = buf.mid(buf.lastIndexOf('/')+1);
        ui->lineEdit->setText(RealfileName);

        if(flag)
        {
            if(buf!=onbuf)
            {
                system("killall -9 madplay");
                system(strChar);
                ui->lineEdit->setText(RealfileName);
                onbuf = buf;
            }
            else
            {
                //system("killall -9 madplay");
                system(strChar);
                ui->lineEdit->setText(RealfileName);
            }


        }
        else
        {
            system("killall -CONT madplay &");
            flag = 1;
            return;
        }

        //show lyric
        QString lyricfile = buf.mid(0,buf.lastIndexOf('.'));
        lyricfile = lyricfile+".txt";

        //open lyricfile and show lyric
        QFile file(lyricfile);
        file.open(QIODevice::ReadOnly);
        QByteArray arr;
        arr = file.readAll();
        ui->textEdit->setText(arr);

        //change current
        while(current->path != buf)
        {
            current = current->next;
        }


        //change label Image
        int num2 = buf.lastIndexOf('/');

        QString pictureName = buf.mid(num2,-1);

        pictureName = pictureName.mid(0,pictureName.lastIndexOf('.'));
        QString pictureName2 =":Image"+pictureName+ "1.jpg";
        pictureName =":Image"+pictureName+ ".jpg";


        //reset widget background
        QPalette palette;
        this->setAutoFillBackground(true);
        QPixmap pixmap;
        pixmap.load(pictureName);
        //palette.setBrush(QPalette::Background,QBrush(pixmap));
        //this->setPalette(palette);

        palette.setBrush(this->backgroundRole(),QBrush(pixmap.scaled(1118,615).scaled(1118,615,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)));
        QPainter p3(&pixmap);
        p3.setCompositionMode(QPainter::CompositionMode_Source);
        p3.drawPixmap(0, 0, pixmap);
        p3.setCompositionMode(QPainter::CompositionMode_DestinationIn);
        this->setPalette(palette);

        //添加标签中的图片
        QMovie *myMovie6 = new QMovie(pictureName2);
        ui->label_4->setMovie(myMovie6);
        ui->label_4->setScaledContents(true);
        myMovie6->start();

        //set opacity
        QGraphicsOpacityEffect* opacityEffect2 = new QGraphicsOpacityEffect;
        opacityEffect2->setOpacity(0);
        ui->label_6->setGraphicsEffect(opacityEffect2);


    });
  1. 暂停键
//暂停 pushButton
    connect(ui->pushButton,&QPushButton::clicked,this,[=](){
        if(songNum == 0)
        {
            QMessageBox::critical(this,"critical","no songs in songList");
            return ;
        }
        system("killall -STOP madplay &");
        flag = 0;
    });
  1. 上一曲
//last一曲
    connect(ui->pushButton_3,&QPushButton::clicked,this,[=](){
        if(songNum == 0)
        {
            QMessageBox::critical(this,"critical","no songs in songList");
            return ;
        }

        buf = QString(MovePrevious());
        onbuf = buf;
        system("killall -9 madplay");
        QString RealfileName = buf.mid(buf.lastIndexOf('/')+1);
        ui->lineEdit->setText(RealfileName);
        QString str =  "madplay "+buf+" &";

        const char* strChar = str.toLatin1();

        system(strChar);
        //show lyric
        QString lyricfile = buf.mid(0,buf.lastIndexOf('.'));
        lyricfile = lyricfile+".txt";

        //open lyricfile and show lyric
        QFile file(lyricfile);
        file.open(QIODevice::ReadOnly);
        QByteArray arr;
        arr = file.readAll();
        ui->textEdit->setText(arr);


        //change label Image
        int num2 = buf.lastIndexOf('/');

        QString pictureName = buf.mid(num2,-1);
        pictureName = pictureName.mid(0,pictureName.lastIndexOf('.'));
        QString pictureName2 =":Image"+pictureName+ "1.jpg";
        pictureName =":Image"+pictureName+ ".jpg";



        //reset widget background
        QPalette palette;
        this->setAutoFillBackground(true);
        QPixmap pixmap;
        pixmap.load(pictureName);
        palette.setBrush(QPalette::Background,QBrush(pixmap));
        palette.setBrush(this->backgroundRole(),QBrush(pixmap.scaled(1118,615).scaled(1118,615,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)));
        QPainter p3(&pixmap);
        p3.setCompositionMode(QPainter::CompositionMode_Source);
        p3.drawPixmap(0, 0, pixmap);
        p3.setCompositionMode(QPainter::CompositionMode_DestinationIn);
        this->setPalette(palette);

        //添加标签中的图片
        QMovie *myMovie6 = new QMovie(pictureName2);
        ui->label_4->setMovie(myMovie6);
        ui->label_4->setScaledContents(true);
        myMovie6->start();

        //set opacity
        QGraphicsOpacityEffect* opacityEffect2 = new QGraphicsOpacityEffect;
        opacityEffect2->setOpacity(0);
        ui->label_6->setGraphicsEffect(opacityEffect2);


    });
  1. 下一曲
//next一曲
    //buf = QString(MoveNext());
    connect(ui->pushButton_4,&QPushButton::clicked,this,[=](){

        if(songNum == 0)
        {
            QMessageBox::critical(this,"critical","no songs in songList");
            return ;
        }

        //get filename
        buf = QString(MoveNext());
        onbuf = buf;
        //kill singing song
        system("killall -9 madplay");
        QString RealfileName = buf.mid(buf.lastIndexOf('/')+1);
        ui->lineEdit->setText(RealfileName);
        QString str =  "madplay "+buf+" &";
        const char* strChar = str.toLatin1();

        system(strChar);
        //qDebug() << "bofangyinyue xiayishou" <textEdit->setText(arr);

        //change label Image
        int num2 = buf.lastIndexOf('/');

        QString pictureName = buf.mid(num2,-1);
        pictureName = pictureName.mid(0,pictureName.lastIndexOf('.'));
        QString pictureName2 =":Image"+pictureName+ "1.jpg";
        pictureName =":Image"+pictureName+ ".jpg";



        //reset widget background
        QPalette palette;
        this->setAutoFillBackground(true);
        QPixmap pixmap;
        pixmap.load(pictureName);
        palette.setBrush(QPalette::Background,QBrush(pixmap));
        palette.setBrush(this->backgroundRole(),QBrush(pixmap.scaled(1118,615).scaled(1118,615,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)));
        QPainter p3(&pixmap);
        p3.setCompositionMode(QPainter::CompositionMode_Source);
        p3.drawPixmap(0, 0, pixmap);
        p3.setCompositionMode(QPainter::CompositionMode_DestinationIn);
        this->setPalette(palette);

        //添加标签中的图片
        QMovie *myMovie6 = new QMovie(pictureName2);
        ui->label_4->setMovie(myMovie6);
        ui->label_4->setScaledContents(true);
        myMovie6->start();

        //set opacity
        QGraphicsOpacityEffect* opacityEffect2 = new QGraphicsOpacityEffect;
        opacityEffect2->setOpacity(0);
        ui->label_6->setGraphicsEffect(opacityEffect2);


    });
  1. 随机播放键
//set button_7 random play
    connect(ui->pushButton_7,&QPushButton::clicked,this,[=](){
        //judge error by songNum
        if(songNum == 0)
        {
            QMessageBox::critical(this,"critical","no songs in songList");
            return ;
        }
        system("killall -9 madplay");


        //set randInt
        int randInt = rand()%10+1;


        for(int i = 0 ;inext;
        }
        if(current == head)
            current = current->next;
        buf = current->path;

        onbuf = buf;

        QString RealfileName = buf.mid(buf.lastIndexOf('/')+1);
        ui->lineEdit->setText(RealfileName);
        QString str =  "madplay "+buf+" &";

        const char* strChar = str.toLatin1();

        system(strChar);
        //show lyric
        QString lyricfile = buf.mid(0,buf.lastIndexOf('.'));
        lyricfile = lyricfile+".txt";

        //open lyricfile and show lyric
        QFile file(lyricfile);
        file.open(QIODevice::ReadOnly);
        QByteArray arr;
        arr = file.readAll();
        ui->textEdit->setText(arr);


        //change label Image
        int num2 = buf.lastIndexOf('/');

        QString pictureName = buf.mid(num2,-1);
        pictureName = pictureName.mid(0,pictureName.lastIndexOf('.'));
        QString pictureName2 =":Image"+pictureName+ "1.jpg";
        pictureName =":Image"+pictureName+ ".jpg";



        //reset widget background
        QPalette palette;
        this->setAutoFillBackground(true);
        QPixmap pixmap;
        pixmap.load(pictureName);
        palette.setBrush(QPalette::Background,QBrush(pixmap));
        palette.setBrush(this->backgroundRole(),QBrush(pixmap.scaled(1118,615).scaled(1118,615,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)));
        QPainter p3(&pixmap);
        p3.setCompositionMode(QPainter::CompositionMode_Source);
        p3.drawPixmap(0, 0, pixmap);
        p3.setCompositionMode(QPainter::CompositionMode_DestinationIn);
        this->setPalette(palette);

        //添加标签中的图片
        QMovie *myMovie6 = new QMovie(pictureName2);
        ui->label_4->setMovie(myMovie6);
        ui->label_4->setScaledContents(true);
        myMovie6->start();

        //set opacity
        QGraphicsOpacityEffect* opacityEffect2 = new QGraphicsOpacityEffect;
        opacityEffect2->setOpacity(0);
        ui->label_6->setGraphicsEffect(opacityEffect2);

    });

  1. 添加歌曲文件
void Widget::on_pushButton_5_clicked()
{

    //select song
    QFileDialog *fdlg = nullptr;
    QString fileName = fdlg->getOpenFileName(this,"open File","/home/itcast/Desktop","(*.mp3)");
    if(fileName == NULL)
        return;
    QString RealfileName = fileName.mid(fileName.lastIndexOf('/')+1);
   
    buf = fileName;
    
    //song add to List
    const char* rfn = RealfileName.toLatin1();
    const char* fn = fileName.toLatin1();
    printf("%s %s\n",rfn,fn);
    bool flag = AddNode(rfn,fn);

    if(flag)
    {
        //add to QListWigetItem
        QListWidgetItem *item = new QListWidgetItem(QIcon(":Image/To-like.png"),RealfileName);
        ui->listWidget->addItem(item);
        item->setTextAlignment(Qt::AlignLeft);

        QString number = QString::number(songNum);
        ui->lineEdit_2->setText(number);
    }else{
        QMessageBox::critical(this,"error","overlap exists");
    }

}
  1. 点击ListWidgetItem进行歌曲切换
void Widget::on_listWidget_itemClicked(QListWidgetItem *item)
{
    buf = item->text();
    buf = "/home/itcast/Desktop/"+buf;

    //change current
    while(current->path != buf)
    {
        current = current->next;
    }
}
  1. 删除歌曲键
void Widget::on_pushButton_6_clicked()
{
    if(songNum == 0)
    {
        QMessageBox::critical(this,"critical","no songs in songList");
        return ;
    }
    QString RealfileName = buf.mid(buf.lastIndexOf('/')+1);

    //foreach to find song to delete
    for(int i=0 ;ilistWidget->item(i)->text() == RealfileName)
        {
            ui->listWidget->takeItem(i);
            songNum--;

            //updata songNum
            QString number = QString::number(songNum);
            ui->lineEdit_2->setText(number);

            RemoveNode(RealfileName);
            QString filename = "/home/itcast/Desktop/"+RealfileName;
            if(onbuf == filename)
            {
                system("killall -9 madplay");

                //reset picture in label_4
                QMovie *myMovie = new QMovie(":Image/CD.png");
                ui->label_4->setMovie(myMovie);
                ui->label_4->setScaledContents(true);
                myMovie->start();

                ui->lineEdit->setText("");
                ui->textEdit->setText("");
                //reset widget background
                QPalette palette;
                this->setAutoFillBackground(true);
                QPixmap pixmap;
                pixmap.load(":Image/default.jpg");
                palette.setBrush(QPalette::Background,QBrush(pixmap));
                this->setPalette(palette);

                //set opacity
                QGraphicsOpacityEffect* opacityEffect2 = new QGraphicsOpacityEffect;
                opacityEffect2->setOpacity(1);
                ui->label_6->setGraphicsEffect(opacityEffect2);

            }
        }
    }
}
  1. 音量条

smallwidget.h

#ifndef SMALLWIDGET_H
#define SMALLWIDGET_H

#include 
#include 
#include 

namespace Ui {
class smallwidget;
}

class smallwidget : public QWidget
{
    Q_OBJECT

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

private slots:
    //void on_spinBox_valueChanged(const QString &arg1);
    //void keyPressEvent( QKeyEvent *k );

private:
    Ui::smallwidget *ui;
};

smallwidget.cpp

#include "smallwidget.h"
#include "ui_smallwidget.h"

smallwidget::smallwidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::smallwidget)
{
    ui->setupUi(this);

    //set spinBox color
    QPalette pal(QColor(255,0,0));
    pal.setColor(QPalette::Background,QColor(255,255,255));
    ui->spinBox->setPalette(pal);

    QPalette pa;
    pa.setColor(QPalette::WindowText,Qt::red);
    ui->spinBox->setPalette(pa);

    //SpinBox connect QSlider
    void(QSpinBox:: * spinSignal)(int) = &QSpinBox::valueChanged;
    connect(ui->spinBox,spinSignal,ui->horizontalSlider,&QSlider::setValue);

    connect(ui->horizontalSlider,&QSlider::valueChanged,ui->spinBox,&QSpinBox::setValue);

    //set init value
    ui->spinBox->setValue(99);

    //click to change volumn
    connect(ui->spinBox,spinSignal,this,[=](){
        int val = ui->spinBox->value();
        QString str = QString::number(val);
        QString setVolume = "amixer set Master "+str+"%";
        qDebug() <
  1. 设置背景图片、字体大小和颜色、透明度等
//set font style
    //set Size
    ui->label_2->setFont(QFont( "Timers" , 12 ,  QFont::Bold));
    ui->label_5->setFont(QFont( "Timers" , 12 ,  QFont::Bold));
    ui->label_6->setFont(QFont( "Timers" , 12 ,  QFont::Bold));
    ui->label->setFont(QFont( "Timers" , 12 ,  QFont::Bold));
    ui->label_3->setFont(QFont( "Timers" , 12 ,  QFont::Bold));


    //set Color
    QPalette pa;
    pa.setColor(QPalette::WindowText,Qt::red);
    QPalette pa1;
    pa1.setColor(QPalette::WindowText,Qt::yellow);
    ui->label_2->setPalette(pa);
    ui->label_5->setPalette(pa);
    ui->label_3->setPalette(pa);
    ui->label_6->setPalette(pa1);
    ui->label->setPalette(pa);
    ui->label_10->setPalette(pa);

    //set button
    QIcon icon(":/Image/pause2.png");
    ui->pushButton->setIcon(icon);
    ui->pushButton_2->setIcon(QIcon(":Image/play2.png"));
    ui->pushButton_3->setIcon(QIcon(":Image/pre2.png"));
    ui->pushButton_4->setIcon(QIcon(":Image/next2.png"));
    ui->pushButton_5->setIcon(QIcon(":Image/addFromLocal.png"));
    ui->pushButton_6->setIcon(QIcon(":Image/clear.png"));
    ui->pushButton_7->setIcon(QIcon(":Image/random2.png"));
    ui->pushButton->setFlat(true);
    ui->pushButton_2->setFlat(true);
    ui->pushButton_3->setFlat(true);
    ui->pushButton_4->setFlat(true);
    ui->pushButton_5->setFlat(true);
    ui->pushButton_6->setFlat(true);
    ui->pushButton_7->setFlat(true);

    //add filename
    QListWidgetItem *item = new QListWidgetItem(QIcon(":Image/music_list.png"),"music list:");
    ui->listWidget->addItem(item);
    item->setTextAlignment(Qt::AlignLeft);
    ui->listWidget->setStyleSheet("background-color:transparent");

//    QString path = "/home/itcast/Desktop/";
//    QString str1 = "1.mp3";
//    QListWidgetItem *item1 = new QListWidgetItem(str1);
//    ui->listWidget->addItem(item1);
//    item1->setTextAlignment(Qt::AlignLeft);

    //添加标签中的图片
    QMovie *myMovie = new QMovie(":Image/CD.png");
    ui->label_4->setMovie(myMovie);
    ui->label_4->setScaledContents(true);
    myMovie->start();

    //set transparency
    QGraphicsOpacityEffect* opacityEffect2 = new QGraphicsOpacityEffect;
    opacityEffect2->setOpacity(0.75);
    ui->label_4->setGraphicsEffect(opacityEffect2);
    //this->setAttribute(Qt::WA_TranslucentBackground);

    QMovie *myMovie2 = new QMovie(":Image/music-playing.png");
    ui->label_7->setMovie(myMovie2);
    ui->label_7->setScaledContents(true);
    myMovie2->start();

    QMovie *myMovie3 = new QMovie(":Image/systemTrayIcon.png");
    ui->label_8->setMovie(myMovie3);
    ui->label_8->setScaledContents(true);
    myMovie3->start();

//set lineEdit style
    ui->lineEdit->setStyleSheet("background-color:transparent");
    ui->lineEdit_2->setStyleSheet("background-color:transparent");
    QPalette palette;
    palette.setColor(QPalette::Text,Qt::red);
    ui->lineEdit->setPalette(palette);
    ui->lineEdit_2->setPalette(palette);
    ui->lineEdit->setFont(QFont( "Timers" , 12 ,  QFont::Bold) );
    ui->lineEdit_2->setFont(QFont( "Timers" , 12 ,  QFont::Bold));

    //set textEdit style
    ui->textEdit->setStyleSheet("background-color:transparent");

    //set Widget image
    this->setAutoFillBackground(true);
    QPixmap pixmap;
    pixmap.load(":Image/default.jpg");
    palette.setBrush(QPalette::Background,QBrush(pixmap));
    this->setPalette(palette);


    //set listWidget font
    ui->listWidget->setFont(QFont( "Timers" , 12 ,  QFont::Bold));
    ui->listWidget->setPalette(palette);

    //set textEdit font
    ui->textEdit->setFont(QFont( "Timers" , 12 ,  QFont::Bold));
    ui->textEdit->setTextColor(Qt::yellow);

    //set textEdit center
    ui->textEdit->setAlignment( Qt::AlignCenter );

7.遇到的问题

  1. 使用在Widget.h的slot中添加的槽函数进行按键的功能书写时,一个函数中两个system无法运行,尝试了让程序睡1秒,也没有解决,最后使用在connect函数中使用lambda表达式书写匿名函数得以实现功能,但这种写法会使代码变得逻辑不清,虽然已成功实现但不推荐这么写
  2. 使用madplay的参数实现进度条功能,未能实现,madplay的参数没有折腾清楚,最后仅剩不到一天的时间才开始看manpage导致时间不够用,而且我现有的编码水平还有差距
  3. Qt环境搭建的问题,在Linux下安装Qt,去官网下载.run的安装包即可,安装过后运行空界面会报错,直接百度这个错误即可得到解决方案,Ubuntu下是需要apt-get install 两个东西,具体是什么有些忘了
  4. 控件设置透明度的问题,折腾了半天,现在还是不清楚,我的做法是不同的控件用的不同的方法,有Platte、QGraphicsOpacityEffect、setFlat(true)三种,具体有关透明度的设置还需要后面去尝试和学习
  5. 文件名加了空格会出错,有中文会出错,因为不知道如何解决,所以暂时规避了空格(这个问题应该是要迎面解决的!),听我的同学说是要在system函数中使用单引号即可,具体成功与否以后尝试
  6. 背景图片的选取,要和主widget的大小匹配,不匹配的话会很模糊,同时要注意让图片适应屏幕大小,具体如何设置我也是百度查到的,上面代码中有

8.总结

刚开始拿到这个题目,只自学了两天Qt的我是懵的,但是能怎么办呢,不闷头干就没有课设成绩,那就干呗!

有问题多思考,多百度,总会有很大的提升,祝看这篇文章的网友们也能写出漂亮的图形化!!!

资源文件下载

alin还在成长的在路上

@alin 2020.6.15

你可能感兴趣的:(alin的学习之路:嵌入式课程设计总结(基于Linux的Qt版MP3播放器))