首页 > 其他分享 >Qt编写网易云界面 (7) -----最新音乐实现

Qt编写网易云界面 (7) -----最新音乐实现

时间:2023-08-27 17:22:33浏览次数:33  
标签:界面 Qt rgb ui setStyleSheet QWidget ----- NewMusic 255

今天数字要实现一下该项目的最新音乐模块,效果如图:

image-20230827171352077

其实这个模块的内容应该是从数据库查询然后再显示,这里就简单的写死了,以后有时间在改了。

最新音乐的qss:

/*最新模块*/
/*最新音乐*/
QPushButton#ptnMusAll,#ptnMusChinese,#ptnMusEurope,
#ptnMusKorea,#ptnMusJapan
{
    color:rgb(103,103,103);
	border:0px;
	background:rgb(255,255,255);
}
 
QPushButton:hover#ptnMusAll,:hover#ptnMusChinese,:hover#ptnMusEurope,
:hover#ptnMusKorea,:hover#ptnMusJapan
{
    color:rgb(69,69,69);
	border:0px;
	background:rgb(255,255,255);
}
 
QPushButton::checked#ptnMusAll,::checked#ptnMusChinese,::checked#ptnMusEurope,
::checked#ptnMusKorea,::checked#ptnMusJapan
{
    color:rgb(69,69,69);
	font-weight: bold;
	border:0px;
	background:rgb(255,255,255);
}
/*全部播放*/
QPushButton#ptnPlayAll
{
	border-image:url(images/NewMusic/playAll.png);
}
/*全部保存*/
QPushButton#ptnSaveAll
{
	border-image:url(images/NewMusic/saveAll.png);
}
 
/**/
QListWidget#listAll
{
	height:400px;
	border:0px;
	color:rgb(55,55,55);
	background:rgb(255,255,255);
}
 
QListWidget::Item#listAll
{
	height:80px;
	border:0px solid rgb(255,255,255);	
	color:rgb(55,55,55);
	background:rgb(255,255,255);
}
 
QListWidget::Item:hover#listAll
{
	border-radius:2px;
	background:rgb(239,239,239);
}
/*选中*/
QListWidget::Item:selected#listAll
{
	border-radius:2px;
	background:rgb(239,239,239);
}

主要代码:

#ifndef NEWCOURIERITEM_H
#define NEWCOURIERITEM_H
 
#include <QWidget>
 
namespace Ui {
class NewCourierItem;
}
 
class NewCourierItem : public QWidget
{
    Q_OBJECT
 
public:
    explicit NewCourierItem(QWidget *parent = nullptr);
    ~NewCourierItem();
 
    //设置id
    void setNum(int id);
    //设置图片
    void setPicture(QString url);
    //设置歌名
    void setMusicName(QString musicName);
    //设置log 默认
    void setLogPic();
    //设置作者
    void setMusicAuthor(QString author);
    //设置专辑
    void setMusicAlbum(QString name);
    //设置timer
    void setMusicTimer(QString strTimer);
 
private:
    Ui::NewCourierItem *ui;
};
 
#endif // NEWCOURIERITEM_H

cpp:

#include "newcourieritem.h"
#include "ui_newcourieritem.h"
 
NewCourierItem::NewCourierItem(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::NewCourierItem)
{
    ui->setupUi(this);
    this->setWindowFlag(Qt::FramelessWindowHint);
    this->setStyleSheet("QWidget{background:transparent; border-radius:8px;}"
                        "QWidget:hover{background:transparent;}");
 
 
}
 
NewCourierItem::~NewCourierItem()
{
    delete ui;
}
 
void NewCourierItem::setNum(int id)
{
    ui->labMusicNum->setNum(id);
    ui->labMusicNum->setStyleSheet("QLabel#labMusicNum{color:rgb(195,195,219);}");
 
}
 
void NewCourierItem::setPicture(QString url)
{
   QString str = "QWidget{border-image:url("+url+");}";
   ui->widMusicPic->setStyleSheet(str);
}
 
void NewCourierItem::setMusicName(QString musicName)
{
    ui->MusicName->setText(musicName);
     ui->MusicName->setStyleSheet("QLabel#MusicName{color:rgb(54,54,54);}");
 
}
 
void NewCourierItem::setLogPic()
{
    ui->labMusicLog->setMaximumSize(27,17);
 
 //   ui->labMusicLog->setStyleSheet("QLable{border-image:url(:/images/NewMusic/sq2.png);}");
}
 
void NewCourierItem::setMusicAuthor(QString author)
{
    ui->MusicAuthor->setText(author);
    ui->MusicAuthor->setStyleSheet("QLabel#MusicAuthor{color:rgb(101,101,101);}");
}
 
void NewCourierItem::setMusicAlbum(QString name)
{
    ui->MusicAlbum->setText(name);
    ui->MusicAlbum->setStyleSheet("QLabel#MusicAlbum{color:rgb(101,101,101);}");
}
 
void NewCourierItem::setMusicTimer(QString strTimer)
{
    ui->MusicTimer->setText(strTimer);
    ui->MusicTimer->setStyleSheet("QLabel#MusicTimer{color:rgb(155,155,202);}");
}

显示代码片段:

#ifndef NEWCOURIER_H
#define NEWCOURIER_H
 
#include <QWidget>
#include <QListWidgetItem>
namespace Ui {
class NewCourier;
}
 
class NewCourier : public QWidget
{
    Q_OBJECT
 
public:
    explicit NewCourier(QWidget *parent = nullptr);
    ~NewCourier();
    //设置对应数据
    void setInitData();
    void setChose(int id);
    void setChinese(); //设置中文
    void setEurope();//设置欧美
    void setKorea(); //设置韩国
    void setJapan(); //设置日文
 
 
private:
    Ui::NewCourier *ui;
};
 
#endif // NEWCOURIER_H
#include "newcourier.h"
#include "ui_newcourier.h"
#include "newcourieritem.h"
NewCourier::NewCourier(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::NewCourier)
{
    ui->setupUi(this);
    setInitData();
}
 
NewCourier::~NewCourier()
{
    delete ui;
}
 
void NewCourier::setInitData()
{
    ui->listAll->clear();
    //
    QListWidgetItem *item = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem = new NewCourierItem();
    nitem->setNum(01); //设置编号
    nitem->setPicture(":/images/NewMusic/01.png");
    nitem->setMusicName("一起向未来");
    nitem->setLogPic();
    nitem->setMusicAuthor("易烊千玺");
    nitem->setMusicAlbum("一起向未来");
    nitem->setMusicTimer("03:19");
    ui->listAll->setItemWidget(item,nitem);
 
    QListWidgetItem *item2 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem2 = new NewCourierItem();
    nitem2->setNum(02); //设置编号
    nitem2->setPicture(":/images/NewMusic/02.png");
    nitem2->setMusicName("灯牌");
    nitem2->setLogPic();
    nitem2->setMusicAuthor("刘也");
    nitem2->setMusicAlbum("朝圣者");
    nitem2->setMusicTimer("05:20");
    ui->listAll->setItemWidget(item2,nitem2);
 
    QListWidgetItem *item3 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem3 = new NewCourierItem();
    nitem3->setNum(03); //设置编号
    nitem3->setPicture(":/images/NewMusic/03.png");
    nitem3->setMusicName("漠河舞厅2020");
    nitem3->setLogPic();
    nitem3->setMusicAuthor("柳爽");
    nitem3->setMusicAlbum("漠河舞厅2020");
    nitem3->setMusicTimer("05:04");
    ui->listAll->setItemWidget(item3,nitem3);
 
    QListWidgetItem *item4 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem4 = new NewCourierItem();
    nitem4->setNum(04); //设置编号
    nitem4->setPicture(":/images/NewMusic/04.png");
    nitem4->setMusicName("B级鲨鱼");
    nitem4->setLogPic();
    nitem4->setMusicAuthor("裴德");
    nitem4->setMusicAlbum("B级鲨鱼");
    nitem4->setMusicTimer("03:51");
    ui->listAll->setItemWidget(item4,nitem4);
 
    QListWidgetItem *item5 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem5 = new NewCourierItem();
    nitem5->setNum(05); //设置编号
    nitem5->setPicture(":/images/NewMusic/05.png");
    nitem5->setMusicName("春天花会开");
    nitem5->setLogPic();
    nitem5->setMusicAuthor("张杰");
    nitem5->setMusicAlbum("时光音乐会");
    nitem5->setMusicTimer("04:14");
    ui->listAll->setItemWidget(item5,nitem5);
}
 
void NewCourier::setChose(int id)
{
    switch (id) {
    case 0:
        setInitData();
        break;
    case 1:
        setChinese();
        break;
    case 2:
        setEurope();
        break;
    case 3:
        setKorea();
        break;
    case 4:
        setJapan();
        break;
    }
}
 
void NewCourier::setChinese()
{
    ui->listAll->clear();
    //
    QListWidgetItem *item = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem = new NewCourierItem();
    nitem->setNum(01); //设置编号
    nitem->setPicture(":/images/NewMusic/06.png");
    nitem->setMusicName("宣言");
    nitem->setLogPic();
    nitem->setMusicAuthor("赵磊");
    nitem->setMusicAlbum("进击之月");
    nitem->setMusicTimer("04:28");
    ui->listAll->setItemWidget(item,nitem);
 
    QListWidgetItem *item2 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem2 = new NewCourierItem();
    nitem2->setNum(02); //设置编号
    nitem2->setPicture(":/images/NewMusic/01.png");
    nitem2->setMusicName("一起向未来");
    nitem2->setLogPic();
    nitem2->setMusicAuthor("易烊千玺");
    nitem2->setMusicAlbum("一起向未来");
    nitem2->setMusicTimer("03:19");
    ui->listAll->setItemWidget(item2,nitem2);
 
    QListWidgetItem *item3 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem3 = new NewCourierItem();
    nitem3->setNum(03); //设置编号
    nitem3->setPicture(":/images/NewMusic/03.png");
    nitem3->setMusicName("漠河舞厅2020");
    nitem3->setLogPic();
    nitem3->setMusicAuthor("柳爽");
    nitem3->setMusicAlbum("漠河舞厅2020");
    nitem3->setMusicTimer("05:04");
    ui->listAll->setItemWidget(item3,nitem3);
 
    QListWidgetItem *item4 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem4 = new NewCourierItem();
    nitem4->setNum(04); //设置编号
    nitem4->setPicture(":/images/NewMusic/04.png");
    nitem4->setMusicName("B级鲨鱼");
    nitem4->setLogPic();
    nitem4->setMusicAuthor("裴德");
    nitem4->setMusicAlbum("B级鲨鱼");
    nitem4->setMusicTimer("03:51");
    ui->listAll->setItemWidget(item4,nitem4);
 
    QListWidgetItem *item5 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem5 = new NewCourierItem();
    nitem5->setNum(05); //设置编号
    nitem5->setPicture(":/images/NewMusic/05.png");
    nitem5->setMusicName("春天花会开");
    nitem5->setLogPic();
    nitem5->setMusicAuthor("张杰");
    nitem5->setMusicAlbum("时光音乐会");
    nitem5->setMusicTimer("04:14");
    ui->listAll->setItemWidget(item5,nitem5);
}
 
void NewCourier::setEurope()
{
    ui->listAll->clear();
    //
    QListWidgetItem *item = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem = new NewCourierItem();
    nitem->setNum(01); //设置编号
    nitem->setPicture(":/images/NewMusic/07.png");
    nitem->setMusicName("Fay As Me");
    nitem->setLogPic();
    nitem->setMusicAuthor("Bruno Mars");
    nitem->setMusicAlbum("An Evening With Silk Sonic");
    nitem->setMusicTimer("03:39");
    ui->listAll->setItemWidget(item,nitem);
 
    QListWidgetItem *item2 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem2 = new NewCourierItem();
    nitem2->setNum(02); //设置编号
    nitem2->setPicture(":/images/NewMusic/08.png");
    nitem2->setMusicName("Already Dead");
    nitem2->setLogPic();
    nitem2->setMusicAuthor("Juice WRLD");
    nitem2->setMusicAlbum("Already Dead");
    nitem2->setMusicTimer("03:51");
    ui->listAll->setItemWidget(item2,nitem2);
 
    QListWidgetItem *item3 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem3 = new NewCourierItem();
    nitem3->setNum(03); //设置编号
    nitem3->setPicture(":/images/NewMusic/09.png");
    nitem3->setMusicName("Be Alive");
    nitem3->setLogPic();
    nitem3->setMusicAuthor("Beyonce");
    nitem3->setMusicAlbum("Be Alive");
    nitem3->setMusicTimer("03:40");
    ui->listAll->setItemWidget(item3,nitem3);
 
    QListWidgetItem *item4 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem4 = new NewCourierItem();
    nitem4->setNum(04); //设置编号
    nitem4->setPicture(":/images/NewMusic/10.png");
    nitem4->setMusicName("Bite Me");
    nitem4->setLogPic();
    nitem4->setMusicAuthor("Avril Lavigne");
    nitem4->setMusicAlbum("Bite Me");
    nitem4->setMusicTimer("02:39");
    ui->listAll->setItemWidget(item4,nitem4);
 
    QListWidgetItem *item5 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem5 = new NewCourierItem();
    nitem5->setNum(05); //设置编号
    nitem5->setPicture(":/images/NewMusic/11.png");
    nitem5->setMusicName("World We Used To Know");
    nitem5->setLogPic();
    nitem5->setMusicAuthor("Alan");
    nitem5->setMusicAlbum("World We Used To Know");
    nitem5->setMusicTimer("04:14");
    ui->listAll->setItemWidget(item5,nitem5);
}
 
void NewCourier::setKorea()
{
    ui->listAll->clear();
    //
    QListWidgetItem *item = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem = new NewCourierItem();
    nitem->setNum(01); //设置编号
    nitem->setPicture(":/images/NewMusic/12.png");
    nitem->setMusicName("거대한 말");
    nitem->setLogPic();
    nitem->setMusicAuthor("B1A4");
    nitem->setMusicAlbum("거대한 말");
    nitem->setMusicTimer("03:56");
    ui->listAll->setItemWidget(item,nitem);
 
    QListWidgetItem *item2 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem2 = new NewCourierItem();
    nitem2->setNum(02); //设置编号
    nitem2->setPicture(":/images/NewMusic/13.png");
    nitem2->setMusicName("SNAPSHOT");
    nitem2->setLogPic();
    nitem2->setMusicAuthor("jessica");
    nitem2->setMusicAlbum("제시카 & 크리스탈 - US로드");
    nitem2->setMusicTimer("03:10");
    ui->listAll->setItemWidget(item2,nitem2);
 
    QListWidgetItem *item3 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem3 = new NewCourierItem();
    nitem3->setNum(03); //设置编号
    nitem3->setPicture(":/images/NewMusic/14.png");
    nitem3->setMusicName("DAYDREAM");
    nitem3->setLogPic();
    nitem3->setMusicAuthor("jessica");
    nitem3->setMusicAlbum("제시카 & 크리스탈 - US로드");
    nitem3->setMusicTimer("05:04");
    ui->listAll->setItemWidget(item3,nitem3);
 
    QListWidgetItem *item4 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem4 = new NewCourierItem();
    nitem4->setNum(04); //设置编号
    nitem4->setPicture(":/images/NewMusic/15.png");
    nitem4->setMusicName("같은 곳을 향해가");
    nitem4->setLogPic();
    nitem4->setMusicAuthor("유지현 김상지");
    nitem4->setMusicAlbum("같은 곳을 향해가");
    nitem4->setMusicTimer("03:51");
    ui->listAll->setItemWidget(item4,nitem4);
 
    QListWidgetItem *item5 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem5 = new NewCourierItem();
    nitem5->setNum(05); //设置编号
    nitem5->setPicture(":/images/NewMusic/16.png");
    nitem5->setMusicName("9号线少女");
    nitem5->setLogPic();
    nitem5->setMusicAuthor("Yourbeagle");
    nitem5->setMusicAlbum("9号线少女");
    nitem5->setMusicTimer("03:00");
    ui->listAll->setItemWidget(item5,nitem5);
}
 
void NewCourier::setJapan()
{
    ui->listAll->clear();
    //
    QListWidgetItem *item = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem = new NewCourierItem();
    nitem->setNum(01); //设置编号
    nitem->setPicture(":/images/NewMusic/17.png");
    nitem->setMusicName("MAKAFUKA");
    nitem->setLogPic();
    nitem->setMusicAuthor("RADWIMPS");
    nitem->setMusicAlbum("FOREVER DAZE");
    nitem->setMusicTimer("05:31");
    ui->listAll->setItemWidget(item,nitem);
 
    QListWidgetItem *item2 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem2 = new NewCourierItem();
    nitem2->setNum(02); //设置编号
    nitem2->setPicture(":/images/NewMusic/18.png");
    nitem2->setMusicName("Chopstick");
    nitem2->setLogPic();
    nitem2->setMusicAuthor("Niziu");
    nitem2->setMusicAlbum("Chopstick");
    nitem2->setMusicTimer("02:57");
    ui->listAll->setItemWidget(item2,nitem2);
 
    QListWidgetItem *item3 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem3 = new NewCourierItem();
    nitem3->setNum(03); //设置编号
    nitem3->setPicture(":/images/NewMusic/19.png");
    nitem3->setMusicName("ラストシーン");
    nitem3->setLogPic();
    nitem3->setMusicAuthor("菅田将暉");
    nitem3->setMusicAlbum("ラストシーン");
    nitem3->setMusicTimer("04:29");
    ui->listAll->setItemWidget(item3,nitem3);
 
    QListWidgetItem *item4 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem4 = new NewCourierItem();
    nitem4->setNum(04); //设置编号
    nitem4->setPicture(":/images/NewMusic/20.png");
    nitem4->setMusicName("starting over");
    nitem4->setLogPic();
    nitem4->setMusicAuthor("三代目");
    nitem4->setMusicAlbum("BEST BROTHERS");
    nitem4->setMusicTimer("04:20");
    ui->listAll->setItemWidget(item4,nitem4);
 
    QListWidgetItem *item5 = new QListWidgetItem(ui->listAll);
    NewCourierItem * nitem5 = new NewCourierItem();
    nitem5->setNum(05); //设置编号
    nitem5->setPicture(":/images/NewMusic/21.png");
    nitem5->setMusicName("Ito");
    nitem5->setLogPic();
    nitem5->setMusicAuthor("TOMORROW X");
    nitem5->setMusicAlbum("Chaotic");
    nitem5->setMusicTimer("04:30");
    ui->listAll->setItemWidget(item5,nitem5);
}

新碟上架模块:

#ifndef NEWDISC_H
#define NEWDISC_H
 
#include <QWidget>
 
namespace Ui {
class NewDisc;
}
 
class NewDisc : public QWidget
{
    Q_OBJECT
 
public:
    explicit NewDisc(QWidget *parent = nullptr);
    ~NewDisc();
    void setInitData();
    void setChose(int id);
    void setChinese(); //设置中文
    void setEurope();//设置欧美
    void setKorea(); //设置韩国
    void setJapan(); //设置日文
 
private:
    Ui::NewDisc *ui;
};
 
#endif // NEWDISC_H
#include "newdisc.h"
#include "ui_newdisc.h"
 
NewDisc::NewDisc(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::NewDisc)
{
    ui->setupUi(this);
    this->setWindowFlag(Qt::FramelessWindowHint);
    this->setStyleSheet("QWidget{background:transparent; border-radius:8px;}"
                        "QWidget:hover{background:transparent;}");
    setInitData();
}
 
NewDisc::~NewDisc()
{
    delete ui;
}
 
void NewDisc::setInitData()
{
    ui->DiscF->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/DiscF.png);}");
    ui->Disc0->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis01.png);}");
    ui->Disc1->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis02.png);}");
    ui->Disc2->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis03.png);}");
    ui->Disc3->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis04.png);}");
    ui->Disc4->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis05.png);}");
    ui->Disc5->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis06.png);}");
    ui->Disc6->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis07.png);}");
    ui->Disc7->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis08.png);}");
    ui->Disc01->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc02->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc03->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc04->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->labName01->setText("进击之月");
    ui->labName01->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu01->setText("赵磊");
    ui->labDiscAu01->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName02->setText("一起向未来");
    ui->labName02->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu02->setText("易烊千玺");
    ui->labDiscAu02->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName03->setText("All Too Well");
    ui->labName03->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu03->setText("Switf");
    ui->labDiscAu03->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName04->setText("B级鲨鱼");
    ui->labName04->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu04->setText("裴德");
    ui->labDiscAu04->setStyleSheet("QLabel{color:rgb(159,159,159);}");
}
 
void NewDisc::setChose(int id)
{
    switch (id) {
    case 0:
        setInitData();
        break;
    case 1:
        setChinese();
        break;
    case 2:
        setEurope();
        break;
    case 3:
        setKorea();
        break;
    case 4:
        setJapan();
        break;
    }
}
 
void NewDisc::setChinese()
{
    ui->DiscF->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/DiscT.png);}");
    ui->Disc0->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis01.png);}");
    ui->Disc1->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis02.png);}");
    ui->Disc2->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis04.png);}");
    ui->Disc3->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis07.png);}");
    ui->Disc4->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis08.png);}");
    ui->Disc5->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis10.png);}");
    ui->Disc6->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis11.png);}");
    ui->Disc7->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis12.png);}");
    ui->Disc01->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc02->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc03->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc04->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->labName01->setText("进击之月");
    ui->labName01->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu01->setText("赵磊");
    ui->labDiscAu01->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName02->setText("一起向未来");
    ui->labName02->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu02->setText("易烊千玺");
    ui->labDiscAu02->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName03->setText("B级鲨鱼");
    ui->labName03->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu03->setText("裴德");
    ui->labDiscAu03->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName04->setText("云");
    ui->labName04->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu04->setText("林鹿言");
    ui->labDiscAu04->setStyleSheet("QLabel{color:rgb(159,159,159);}");
}
 
void NewDisc::setEurope()
{
    ui->DiscF->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/DiscT.png);}");
    ui->Disc0->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis13.png);}");
    ui->Disc1->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis14.png);}");
    ui->Disc2->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis15.png);}");
    ui->Disc3->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis16.png);}");
    ui->Disc4->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis17.png);}");
    ui->Disc5->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis18.png);}");
    ui->Disc6->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis19.png);}");
    ui->Disc7->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis20.png);}");
    ui->Disc01->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc02->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc03->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc04->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->labName01->setText("Fay As Me");
    ui->labName01->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu01->setText("Bruno Mars");
    ui->labDiscAu01->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName02->setText("Already Dead");
    ui->labName02->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu02->setText("Juice WRLD");
    ui->labDiscAu02->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName03->setText("All Too Well");
    ui->labName03->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu03->setText("Switf");
    ui->labDiscAu03->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName04->setText("Bite Me");
    ui->labName04->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu04->setText("Avril Lavigne");
    ui->labDiscAu04->setStyleSheet("QLabel{color:rgb(159,159,159);}");
}
 
void NewDisc::setKorea()
{
    ui->DiscF->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/DiscT.png);}");
    ui->Disc0->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis21.png);}");
    ui->Disc1->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis22.png);}");
    ui->Disc2->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis23.png);}");
    ui->Disc3->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis24.png);}");
    ui->Disc4->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis25.png);}");
    ui->Disc5->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis26.png);}");
    ui->Disc6->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis27.png);}");
    ui->Disc7->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis06.png);}");
    ui->Disc01->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc02->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc03->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc04->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->labName01->setText("거대한 말");
    ui->labName01->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu01->setText("B1A4");
    ui->labDiscAu01->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName02->setText("SNAPSHOT");
    ui->labName02->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu02->setText("jessica");
    ui->labDiscAu02->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName03->setText("DAYDREAM");
    ui->labName03->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu03->setText("jessica");
    ui->labDiscAu03->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName04->setText("같은 곳을 향해가");
    ui->labName04->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu04->setText("유지현 김상지");
    ui->labDiscAu04->setStyleSheet("QLabel{color:rgb(159,159,159);}");
}
 
void NewDisc::setJapan()
{
    ui->DiscF->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/DiscT.png);}");
    ui->Disc0->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis28.png);}");
    ui->Disc1->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis29.png);}");
    ui->Disc2->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis30.png);}");
    ui->Disc3->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis31.png);}");
    ui->Disc4->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis32.png);}");
    ui->Disc5->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis33.png);}");
    ui->Disc6->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis34.png);}");
    ui->Disc7->setStyleSheet("QWidget{border-image:url(:/images/NewMusic/Dis35.png);}");
    ui->Disc01->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc02->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc03->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->Disc04->setStyleSheet("QWidget{background:rgb(255,255,255);}");
    ui->labName01->setText("MAKAFUKA");
    ui->labName01->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu01->setText("RADWIMPS");
    ui->labDiscAu01->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName02->setText("Chopstick");
    ui->labName02->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu02->setText("Niziu");
    ui->labDiscAu02->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName03->setText("ラストシーン");
    ui->labName03->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu03->setText("菅田将暉");
    ui->labDiscAu03->setStyleSheet("QLabel{color:rgb(159,159,159);}");
    ui->labName04->setText("starting over");
    ui->labName04->setStyleSheet("QLabel{color:rgb(55,55,55);}");
    ui->labDiscAu04->setText("三代目");
    ui->labDiscAu04->setStyleSheet("QLabel{color:rgb(159,159,159);}");
}

主要加载:

 
void AllMain::setNewMusicButton()
{
    ui->widNewMus->setGeometry(280,10,232,32);
    ui->widNewMus->setStyleSheet("QWidget#widNewMus{background:rgb(255,255,255);border:1px solid rgb(187,187,187);border-radius:16px;}");
    ui->ptnNew->setParent(ui->widNewMus);
    ui->ptnNew->setGeometry(0,1,115,30);
    ui->ptnNew->move(1,1);
    ui->ptnNew->setCheckable(true);
    ui->ptnNew2->setParent(ui->widNewMus);
    ui->ptnNew2->setGeometry(ui->ptnNew->width()+2,1,115,30);
    ui->ptnNew2->move(ui->ptnNew->width()+1,1);
    ui->ptnNew2->setCheckable(true);
    ui->ptnNew->setStyleSheet("QPushButton{color:rgb(55,55,55);border:0px;background:rgb(255,255,255);border-radius:14px;}"
                            "QPushButton:hover{border:0px;background:rgb(244,244,244);border-radius:14px;}"
                            "QPushButton:checked{color:rgb(255,255,255);border:0px;background:rgb(187,187,187);border-radius:14px;}");
    ui->ptnNew2->setStyleSheet("QPushButton{color:rgb(55,55,55);border:0px;background:rgb(255,255,255);border-radius:14px;}"
                            "QPushButton:hover{border:0px;background:rgb(244,244,244);border-radius:14px;}"
                            "QPushButton:checked{color:rgb(255,255,255);border:0px;background:rgb(187,187,187);border-radius:14px;}");
    QButtonGroup * btnGroup = new QButtonGroup(this);
    btnGroup->addButton(ui->ptnNew,0);
    btnGroup->addButton(ui->ptnNew2,1);
    btnGroup->setExclusive(true);
    btnGroup->button(0)->setChecked(true);
 
    //连接槽
    connect(btnGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
          [=](int id){
          //这里处理对应界面
        setShowWidget(id);
    });
}
 
void AllMain::setShowWidget(int id)
{
    currentFlog = id;
    changeChose();
 
}
 
void AllMain::setNewMusicChooseButton()
{
    QButtonGroup * btnGroup = new QButtonGroup(this);
    btnGroup->addButton(ui->ptnMusAll,0);
    btnGroup->addButton(ui->ptnMusChinese,1);
    btnGroup->addButton(ui->ptnMusEurope,2);
    btnGroup->addButton(ui->ptnMusKorea,3);
    btnGroup->addButton(ui->ptnMusJapan,4);
    btnGroup->setExclusive(true);
    btnGroup->button(0)->setChecked(true);
 
    //连接槽
    connect(btnGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
          [=](int id){
          //这里处理对应界面
          setLanguageChose(id);
    });
 
}
 
void AllMain::setAddWidget()
{
   pCourier = new NewCourier;
   pDisMusic = new NewDisc;
   stackedLayout = new QStackedLayout;
   stackedLayout->addWidget(pCourier);
   stackedLayout->addWidget(pDisMusic);
   pCourier->move(0,0);
   ui->verAddWidget->addLayout(stackedLayout);
   stackedLayout->setCurrentIndex(0);
 
}
 
void AllMain::setLanguageChose(int id)
{
    currentClass = id;
    changeChose();
}
 
void AllMain::changeChose()
{
    if(currentFlog == 0)
    {
       pCourier->setChose(currentClass);
       stackedLayout->setCurrentIndex(0);
    }
    else if (currentFlog == 1) {
       pDisMusic->setChose(currentClass);
       stackedLayout->setCurrentIndex(1);
    }
}

标签:界面,Qt,rgb,ui,setStyleSheet,QWidget,-----,NewMusic,255
From: https://www.cnblogs.com/dwinternet/p/17660521.html

相关文章

  • MFC-剪贴板
     复制文本到剪贴板 //**********复制文本到剪贴板**********CStringtext=_T("我是中国人");BOOLb=OpenClipboard();//打开剪贴板/*返回值:如果通过CWnd打开了剪贴板,则返回非零值如果其他应用程序或窗口已经打开......
  • 【pandas小技巧】--花哨的DataFrame
    最近github上发现了一个库(plottable),可以用简单的方式就设置出花哨的DataFrame样式。github上的地址:https://github.com/znstrider/plottable1.安装通过pip安装:pipinstallplottable2.行的颜色使用plottable的API,调整背景和字体的颜色非常方便。2.1.奇偶行不同颜......
  • 面试类-Java并发编程(三)
    39.CountDownLatch(倒计数器)了解吗?CountDownLatch,倒计数器,有两个常见的应用场景[18]:场景1:协调子线程结束动作:等待所有子线程运行结束CountDownLatch允许一个或多个线程等待其他线程完成操作。例如,我们很多人喜欢玩的王者荣耀,开黑的时候,得等所有人都上线之后,才能开打。   ......
  • 设备驱动-14.userspace进行IP的寄存器读写
    1定义寄存器以键盘keyscan为例,定义一个IP寄存器描述头文件,IOCRREG,IOCWREG定义了两个ioctl命令,用来读写寄存器。structmsg用来存放寄存器地址和值。/*Keyscanregister:addr+offset+mask*/#definekeyscan_top_keyscan_config1 0x0#definekeyscan_top_keyscan_......
  • qt5 odbc mysql 开发配置
    qt5应用odbc使用mysql 要点apt-getinstallmysql-serverapt-getinstallmysqlclient-dev配置mysql-server可以安装apt-getinstallmysql-workbenchapt-getinstallmysql-connector-odbc配置/etc/odbc.ini/etc/odbcinst.iniapt-getinstallunixodbcisqlDNS-v......
  • 高斯白噪声下雷达测量精度---------速度精度公式详细推导
    今天来到了深圳市图书馆,有一说一座位挺多的,地方也挺大的,可能是时间比较长了。没有光明区的图书馆特别让人惊艳。而且连WIFI还需要读者证号,有一点不方便。回到正题,承接上回,上一篇学习了高斯白噪声下雷达距离精度公式详细推导,给出了详细的推导过程。接下来我们接着来学习高斯白......
  • 文心一言 VS 讯飞星火 VS chatgpt (82)-- 算法导论8.1 1题
    一、如果用go语言,在一棵比较排序算法的决策树中,一个叶结点可能的最小深度是多少?文心一言:在一个排序决策树(如二叉搜索树)中,每个叶节点的最小深度等于输入数据中最大元素与最小元素之间的位距离。这是因为在最坏的情况下,每个比较都需要将最大元素向最小元素的路径移动,因此叶节点的最......
  • openGauss学习笔记-52 openGauss 高级特性-LLVM
    openGauss学习笔记-52openGauss高级特性-LLVMopenGauss借助LLVM(LowLevelVirtualMachine)提供的库函数,依据查询执行计划树,将原本在执行器阶段才会确定查询实际执行路径的过程提前到执行初始化阶段,从而规避原本查询执行时候伴随的函数调用、逻辑条件分支判断以及大量的数据读取......
  • CSP-J2022初赛易错题解析
    7.假设字母表{a,b,c,d,e}在字符串出现的频率分别为10%,15%,30%,16%,29%。若使用哈夫曼编码方式对字母进行不定长的二进制编码,字母d的编码长度()位。A.1  B.2 C.2或3  D.3正解:画出哈夫曼树即可9.考虑由N个顶点构成的有向连通图,采用邻接矩阵的数据结构表示时,该矩阵中至......
  • CSP-J2020初赛易错题解析
    一.5. 正解:冒泡排序最少比较n-1次,即单调上升序列 10.5 个小朋友并排站成一列,其中有两个小朋友是双胞胎,如果要求这两个双胞胎必须相邻,则有()种不同排列方法?A.24 B.36 C.72 D.48错误原因:忘记乘上A(2,2)了正解:捆绑法,A(4,4)*A(2,2)=48 15.有五副不同颜色的手套(......