暂时删除背景,界面调整为固定大小

This commit is contained in:
flykhan 2023-08-31 16:06:03 +08:00
parent fd2d480e33
commit bb93831252
2 changed files with 15 additions and 1 deletions

View File

@ -4,6 +4,7 @@
int mplayer_pid; int mplayer_pid;
pthread_t t1,t2; // pthread_t t1,t2; //
char current_song_path_name[128] = "";
void *getTimerThreadFunc(void *arg); // 发送获取当前时间的 mplayer 命令 void *getTimerThreadFunc(void *arg); // 发送获取当前时间的 mplayer 命令
void *readPipeMSG(void *arg); // 获取当前时间的线程 void *readPipeMSG(void *arg); // 获取当前时间的线程
@ -13,6 +14,15 @@ MainWindow::MainWindow(QWidget *parent)
, ui(new Ui::MainWindow) , ui(new Ui::MainWindow)
{ {
ui->setupUi(this); 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(); // 初始化主界面 initMainWindow(); // 初始化主界面
mplayerInit(); // 初始化 mplayer mplayerInit(); // 初始化 mplayer
kill(mplayer_pid,SIGSTOP); kill(mplayer_pid,SIGSTOP);
@ -36,8 +46,10 @@ void MainWindow::initMainWindow()
{ {
// 设置主窗体属性 // 设置主窗体属性
setWindowTitle("音乐播放器"); setWindowTitle("音乐播放器");
setFixedSize(1055,750);
setWindowIcon(QIcon(":/icon/button")); setWindowIcon(QIcon(":/icon/button"));
// 设置子组件背景透明 // 设置子组件背景透明
ui->song_list_widget->setAttribute(Qt::WA_TranslucentBackground); ui->song_list_widget->setAttribute(Qt::WA_TranslucentBackground);
ui->label_artist->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_right_label->setAttribute(Qt::WA_TranslucentBackground);
ui->time_widget->setAttribute(Qt::WA_TranslucentBackground); ui->time_widget->setAttribute(Qt::WA_TranslucentBackground);
// 设置按钮属性
// 设置滑块属性 // 设置滑块属性
ui->time_slider->setStyleSheet("QSlider::groove:horizontal { background-color: white; }" ui->time_slider->setStyleSheet("QSlider::groove:horizontal { background-color: white; }"
"QSlider::handle:horizontal { background-color: yellow; width: 20px;}"); "QSlider::handle:horizontal { background-color: yellow; width: 20px;}");

View File

@ -14,7 +14,7 @@
<string>MainWindow</string> <string>MainWindow</string>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-image: url(:/img/background5);</string> <string notr="true">background-color: rgb(136, 138, 133);</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="widget_show" native="true"> <widget class="QWidget" name="widget_show" native="true">