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