-
Notifications
You must be signed in to change notification settings - Fork 0
/
musiclist.cpp
45 lines (37 loc) · 993 Bytes
/
musiclist.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "musiclist.h"
#include "ui_musiclist.h"
MusicList::MusicList(QWidget *parent) :
QWidget(parent),
ui(new Ui::MusicList)
{
/// 通用音乐列表
ui->setupUi(this);
}
MusicList::~MusicList()
{
delete ui;
}
void MusicList::addMusic(MusicItemData &data){
MusicItem *item=new MusicItem(data);
QListWidgetItem *ITEM = new QListWidgetItem(ui->content);
ITEM->setSizeHint(QSize(400,48));
ui->content->addItem(ITEM);
data.faBtn=item->findChild<QPushButton*>("shou");
ui->content->setItemWidget(ITEM, item);
}
void MusicList::addMusic(QList<MusicItemData> &data){
for(int i=0;i<data.size();i++){
data[i].index=i+1;
addMusic(data[i]);
}
}
void MusicList::removeMusic(const int &index) const{
ui->content->takeItem(index);
}
void MusicList::clearMusic() const{
ui->content->clear();
}
void MusicList::on_content_itemClicked(QListWidgetItem *item)
{
((MusicItem*)ui->content->itemWidget(item))->playSelf();
}