1 Star 0 Fork 0

tredy6t/QQ-Music-With-Qt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
trylistenwidget.cpp 3.47 KB
一键复制 编辑 原始数据 按行查看 历史
LeviInfinity 提交于 2017-05-25 07:46 . qt模仿qq音乐界面
#include "trylistenwidget.h"
#include<QHBoxLayout>
#include<QVBoxLayout>
#include<QHeaderView>
#include<QScrollBar>
TryListenWidget::TryListenWidget(QWidget *parent) : QWidget(parent)
{
InitWidget();
QVBoxLayout *main_lay=new QVBoxLayout(this);
main_lay->setSpacing(10);
main_lay->setContentsMargins(20,20,20,0);
main_lay->addWidget(textLabel);
QHBoxLayout *btnLay=new QHBoxLayout;
btnLay->setSpacing(15);
btnLay->setContentsMargins(0,0,0,0);
btnLay->addWidget(playAllBtn);
btnLay->addWidget(downLoad);
btnLay->addStretch();
btnLay->addWidget(searchEdit);
main_lay->addLayout(btnLay);
main_lay->addWidget(tableWidget);
setStyle(":/qss/center");
}
TryListenWidget::~TryListenWidget()
{
}
void TryListenWidget::InitWidget()
{
textLabel=new QLabel("试听列表");//标题
playAllBtn=new QPushButton(QIcon(":/center/play"),"播放全部");
downLoad = new QPushButton(QIcon(":/center/download"),"下载");
searchEdit=new QLineEdit;
searchEdit->setFixedHeight(28);
searchEdit->setPlaceholderText("在试听列表中搜索");
searchAction=new QAction(QIcon(":/title/search"),tr("搜索"),this);
searchEdit->addAction(searchAction,QLineEdit::TrailingPosition);
tableWidget = new QTableWidget(20,4);
QStringList header;
header<<"歌曲"<<"歌手"<<"专辑"<<"时长";
tableWidget->setHorizontalHeaderLabels(header);//插入表头
tableWidget->verticalHeader()->setVisible(false);
tableWidget->setItem(0,0,new QTableWidgetItem("半城烟沙"));
tableWidget->setItem(0,1,new QTableWidgetItem("许嵩"));
tableWidget->setItem(0,2,new QTableWidgetItem("半城烟沙"));
tableWidget->setItem(0,3,new QTableWidgetItem("04:52"));
tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);//设置选中一行
tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);//设置不可编辑
tableWidget->setColumnWidth(0,300);
tableWidget->setColumnWidth(1,180);
tableWidget->setColumnWidth(2,180);
tableWidget->setColumnWidth(3,100);
//tableWidget->setRowHeight(0,60);
tableWidget->setStyleSheet("QTableWidget{\
font-size:13px; \
font-weight:300;\
color: rgb(60,60,60);\
gridline-color: white;\
alternate-background: #3A3A3C;\
selection-background-color: rgb(210,210,210);\
selection-color:rgb(60,60,60);\
border: 2px groove gray;\
border-radius: 0px;\
border:1px solid rgb(220,220,220);}\
}");
tableWidget->verticalScrollBar()->setStyleSheet("QScrollBar{background:rgb(230,230,230); width:12px;}\
QScrollBar::handle:vertical {\
background-color:rgb(200,200,200);\
border-radius: 6px;\
min-height: 5px;\
}\
");
}
void TryListenWidget::setStyle(const QString &style)
{
QFile qss(style);
qss.open(QFile::ReadOnly);
setStyleSheet(qss.readAll());
qss.close();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tredy6t/QQ-Music-With-Qt.git
[email protected]:tredy6t/QQ-Music-With-Qt.git
tredy6t
QQ-Music-With-Qt
QQ-Music-With-Qt
master

搜索帮助