From bb93831252ea1d7faad81f103069474ae0b854ee Mon Sep 17 00:00:00 2001 From: flykhan Date: Thu, 31 Aug 2023 16:06:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=88=A0=E9=99=A4=E8=83=8C?= =?UTF-8?q?=E6=99=AF=EF=BC=8C=E7=95=8C=E9=9D=A2=E8=B0=83=E6=95=B4=E4=B8=BA?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mainwindow.cpp | 14 ++++++++++++++ mainwindow.ui | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 634599e..ed735b8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -4,6 +4,7 @@ int mplayer_pid; pthread_t t1,t2; // +char current_song_path_name[128] = ""; void *getTimerThreadFunc(void *arg); // 发送获取当前时间的 mplayer 命令 void *readPipeMSG(void *arg); // 获取当前时间的线程 @@ -13,6 +14,15 @@ MainWindow::MainWindow(QWidget *parent) , ui(new Ui::MainWindow) { ui->setupUi(this); + + + QSize windowSize = QSize(geometry().width(), geometry().height()); + // 设置背景图片 + setAutoFillBackground(true); + QPalette pal = this->palette(); + pal.setBrush(backgroundRole(),QPixmap(":/img/background1").scaled(windowSize, Qt::KeepAspectRatio)); + setPalette(pal); + initMainWindow(); // 初始化主界面 mplayerInit(); // 初始化 mplayer kill(mplayer_pid,SIGSTOP); @@ -36,8 +46,10 @@ void MainWindow::initMainWindow() { // 设置主窗体属性 setWindowTitle("音乐播放器"); + setFixedSize(1055,750); setWindowIcon(QIcon(":/icon/button")); + // 设置子组件背景透明 ui->song_list_widget->setAttribute(Qt::WA_TranslucentBackground); ui->label_artist->setAttribute(Qt::WA_TranslucentBackground); @@ -52,6 +64,8 @@ void MainWindow::initMainWindow() ui->time_right_label->setAttribute(Qt::WA_TranslucentBackground); ui->time_widget->setAttribute(Qt::WA_TranslucentBackground); + // 设置按钮属性 + // 设置滑块属性 ui->time_slider->setStyleSheet("QSlider::groove:horizontal { background-color: white; }" "QSlider::handle:horizontal { background-color: yellow; width: 20px;}"); diff --git a/mainwindow.ui b/mainwindow.ui index 82c396a..554ebd7 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -14,7 +14,7 @@ MainWindow - background-image: url(:/img/background5); + background-color: rgb(136, 138, 133);