界面v2: 添加音量滑块范围,添加部分注释
This commit is contained in:
parent
5533d5fe62
commit
13aeecc6c3
|
@ -6,7 +6,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
initMainWindow(); // 初始化界面
|
initMainWindow(); // 初始化主界面
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -16,7 +16,10 @@ MainWindow::~MainWindow()
|
||||||
|
|
||||||
void MainWindow::initMainWindow()
|
void MainWindow::initMainWindow()
|
||||||
{
|
{
|
||||||
|
// 设置主窗体属性
|
||||||
setWindowTitle("音乐播放器");
|
setWindowTitle("音乐播放器");
|
||||||
|
|
||||||
|
// 设置子组件背景透明
|
||||||
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);
|
||||||
ui->label_song_list->setAttribute(Qt::WA_TranslucentBackground);
|
ui->label_song_list->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
@ -28,9 +31,21 @@ void MainWindow::initMainWindow()
|
||||||
ui->widget_3->setAttribute(Qt::WA_TranslucentBackground);
|
ui->widget_3->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
ui->time_left_label->setAttribute(Qt::WA_TranslucentBackground);
|
ui->time_left_label->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
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_slider->setStyleSheet("QSlider::groove:horizontal { background-color: white; }"
|
ui->time_slider->setStyleSheet("QSlider::groove:horizontal { background-color: white; }"
|
||||||
"QSlider::handle:horizontal { background-color: blue; width: 20px;}");
|
"QSlider::handle:horizontal { background-color: blue; width: 20px;}");
|
||||||
ui->volume_slider->setStyleSheet("QSlider::groove:horizontal { background-color: gray; }"
|
ui->volume_slider->setStyleSheet("QSlider::groove:horizontal { background-color: gray; }"
|
||||||
"QSlider::handle:horizontal { background-color: yellow; width: 20px;}");
|
"QSlider::handle:horizontal { background-color: yellow; width: 20px;}");
|
||||||
|
ui->volume_slider->setMinimum(0); // 最小音量 0
|
||||||
|
ui->volume_slider->setMaximum(100); // 最大音量 100
|
||||||
|
// 当前音量从 mplayer 属性获取
|
||||||
|
|
||||||
|
// QSlider* slider = new QSlider(Qt::Horizontal);
|
||||||
|
// slider->setMinimum(0); // 设置最小值
|
||||||
|
// slider->setMaximum(100); // 设置最大值
|
||||||
|
// slider->setValue(50); // 设置当前值
|
||||||
|
// slider->setSingleStep(1); // 设置步长
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,7 @@
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">font: 12pt "微软雅黑";color: rgb(255, 255, 0);
|
<string notr="true">font: 12pt "微软雅黑";color: rgb(255, 255, 0);</string>
|
||||||
background-image: url(:/img/background2);</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QListWidget" name="song_list_widget">
|
<widget class="QListWidget" name="song_list_widget">
|
||||||
|
@ -234,19 +233,6 @@ color: rgb(255, 255, 0);</string>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QSlider" name="time_slider">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>130</x>
|
|
||||||
<y>550</y>
|
|
||||||
<width>421</width>
|
|
||||||
<height>20</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="volume_widget" native="true">
|
<widget class="QWidget" name="volume_widget" native="true">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
|
@ -323,32 +309,39 @@ color: rgb(255, 255, 0);</string>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="time_left_label">
|
<widget class="QWidget" name="time_widget" native="true">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>40</x>
|
<x>50</x>
|
||||||
<y>550</y>
|
<y>550</y>
|
||||||
<width>72</width>
|
<width>581</width>
|
||||||
<height>15</height>
|
<height>40</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="time_left_label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>TextLabel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="time_right_label">
|
</item>
|
||||||
<property name="geometry">
|
<item>
|
||||||
<rect>
|
<widget class="QSlider" name="time_slider">
|
||||||
<x>570</x>
|
<property name="orientation">
|
||||||
<y>550</y>
|
<enum>Qt::Horizontal</enum>
|
||||||
<width>72</width>
|
|
||||||
<height>15</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="time_right_label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>TextLabel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
|
|
Loading…
Reference in New Issue