Skip to content

Commit 5a9841f

Browse files
committed
day 26
1 parent 6fa3adc commit 5a9841f

File tree

5 files changed

+312
-0
lines changed

5 files changed

+312
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
QT += core gui
2+
3+
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4+
5+
CONFIG += c++11
6+
7+
# The following define makes your compiler emit warnings if you use
8+
# any Qt feature that has been marked deprecated (the exact warnings
9+
# depend on your compiler). Please consult the documentation of the
10+
# deprecated API in order to know how to port your code away from it.
11+
DEFINES += QT_DEPRECATED_WARNINGS
12+
13+
# You can also make your code fail to compile if it uses deprecated APIs.
14+
# In order to do so, uncomment the following line.
15+
# You can also select to disable deprecated APIs only up to a certain version of Qt.
16+
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17+
18+
SOURCES += \
19+
main.cpp \
20+
mainwindow.cpp
21+
22+
HEADERS += \
23+
mainwindow.h
24+
25+
FORMS += \
26+
mainwindow.ui
27+
28+
# Default rules for deployment.
29+
qnx: target.path = /tmp/$${TARGET}/bin
30+
else: unix:!android: target.path = /opt/$${TARGET}/bin
31+
!isEmpty(target.path): INSTALLS += target

02_代码/29_video_player/main.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "mainwindow.h"
2+
3+
#include <QApplication>
4+
5+
int main(int argc, char *argv[])
6+
{
7+
QApplication a(argc, argv);
8+
MainWindow w;
9+
w.show();
10+
return a.exec();
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "mainwindow.h"
2+
#include "ui_mainwindow.h"
3+
4+
MainWindow::MainWindow(QWidget *parent)
5+
: QMainWindow(parent)
6+
, ui(new Ui::MainWindow) {
7+
ui->setupUi(this);
8+
}
9+
10+
MainWindow::~MainWindow() {
11+
delete ui;
12+
}
13+
14+
void MainWindow::on_stopBtn_clicked() {
15+
int count = ui->playWidget->count();
16+
int idx = ui->playWidget->currentIndex();
17+
ui->playWidget->setCurrentIndex(++idx % count);
18+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef MAINWINDOW_H
2+
#define MAINWINDOW_H
3+
4+
#include <QMainWindow>
5+
6+
QT_BEGIN_NAMESPACE
7+
namespace Ui {
8+
class MainWindow;
9+
}
10+
QT_END_NAMESPACE
11+
12+
class MainWindow : public QMainWindow {
13+
Q_OBJECT
14+
15+
public:
16+
MainWindow(QWidget *parent = nullptr);
17+
~MainWindow();
18+
19+
private slots:
20+
void on_stopBtn_clicked();
21+
22+
private:
23+
Ui::MainWindow *ui;
24+
};
25+
#endif // MAINWINDOW_H
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>MainWindow</class>
4+
<widget class="QMainWindow" name="MainWindow">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>921</width>
10+
<height>692</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>MainWindow</string>
15+
</property>
16+
<widget class="QWidget" name="centralwidget">
17+
<layout class="QVBoxLayout" name="verticalLayout">
18+
<item>
19+
<widget class="QStackedWidget" name="playWidget">
20+
<property name="currentIndex">
21+
<number>0</number>
22+
</property>
23+
<widget class="QWidget" name="page">
24+
<layout class="QHBoxLayout" name="horizontalLayout_5">
25+
<item>
26+
<widget class="QPushButton" name="openFileBtn">
27+
<property name="maximumSize">
28+
<size>
29+
<width>70</width>
30+
<height>16777215</height>
31+
</size>
32+
</property>
33+
<property name="text">
34+
<string>打开文件</string>
35+
</property>
36+
</widget>
37+
</item>
38+
</layout>
39+
</widget>
40+
<widget class="QWidget" name="page_2">
41+
<layout class="QGridLayout" name="gridLayout">
42+
<item row="0" column="0">
43+
<widget class="QWidget" name="videoWidget" native="true"/>
44+
</item>
45+
</layout>
46+
</widget>
47+
</widget>
48+
</item>
49+
<item>
50+
<layout class="QHBoxLayout" name="horizontalLayout">
51+
<item>
52+
<layout class="QHBoxLayout" name="horizontalLayout_2">
53+
<item>
54+
<widget class="QPushButton" name="playBtn">
55+
<property name="maximumSize">
56+
<size>
57+
<width>40</width>
58+
<height>16777215</height>
59+
</size>
60+
</property>
61+
<property name="text">
62+
<string>播放</string>
63+
</property>
64+
</widget>
65+
</item>
66+
<item>
67+
<widget class="QPushButton" name="stopBtn">
68+
<property name="maximumSize">
69+
<size>
70+
<width>40</width>
71+
<height>16777215</height>
72+
</size>
73+
</property>
74+
<property name="text">
75+
<string>停止</string>
76+
</property>
77+
</widget>
78+
</item>
79+
<item>
80+
<layout class="QHBoxLayout" name="horizontalLayout_3">
81+
<item>
82+
<widget class="QSlider" name="currentSlider">
83+
<property name="minimumSize">
84+
<size>
85+
<width>350</width>
86+
<height>0</height>
87+
</size>
88+
</property>
89+
<property name="orientation">
90+
<enum>Qt::Horizontal</enum>
91+
</property>
92+
</widget>
93+
</item>
94+
<item>
95+
<widget class="QLabel" name="currentLabel">
96+
<property name="minimumSize">
97+
<size>
98+
<width>0</width>
99+
<height>0</height>
100+
</size>
101+
</property>
102+
<property name="maximumSize">
103+
<size>
104+
<width>70</width>
105+
<height>16777215</height>
106+
</size>
107+
</property>
108+
<property name="font">
109+
<font>
110+
<family>Consolas</family>
111+
</font>
112+
</property>
113+
<property name="text">
114+
<string>00:00:00</string>
115+
</property>
116+
<property name="alignment">
117+
<set>Qt::AlignCenter</set>
118+
</property>
119+
</widget>
120+
</item>
121+
<item>
122+
<widget class="QLabel" name="label_2">
123+
<property name="font">
124+
<font>
125+
<family>Consolas</family>
126+
</font>
127+
</property>
128+
<property name="text">
129+
<string>/</string>
130+
</property>
131+
<property name="alignment">
132+
<set>Qt::AlignCenter</set>
133+
</property>
134+
</widget>
135+
</item>
136+
<item>
137+
<widget class="QLabel" name="durationLabel">
138+
<property name="maximumSize">
139+
<size>
140+
<width>70</width>
141+
<height>16777215</height>
142+
</size>
143+
</property>
144+
<property name="font">
145+
<font>
146+
<family>Consolas</family>
147+
</font>
148+
</property>
149+
<property name="text">
150+
<string>00:00:00</string>
151+
</property>
152+
<property name="alignment">
153+
<set>Qt::AlignCenter</set>
154+
</property>
155+
</widget>
156+
</item>
157+
</layout>
158+
</item>
159+
<item>
160+
<layout class="QHBoxLayout" name="horizontalLayout_4">
161+
<item>
162+
<widget class="QPushButton" name="silenceBtn">
163+
<property name="maximumSize">
164+
<size>
165+
<width>40</width>
166+
<height>16777215</height>
167+
</size>
168+
</property>
169+
<property name="text">
170+
<string>静音</string>
171+
</property>
172+
</widget>
173+
</item>
174+
<item>
175+
<widget class="QSlider" name="volumnSlider">
176+
<property name="minimumSize">
177+
<size>
178+
<width>100</width>
179+
<height>0</height>
180+
</size>
181+
</property>
182+
<property name="maximumSize">
183+
<size>
184+
<width>16777215</width>
185+
<height>16777215</height>
186+
</size>
187+
</property>
188+
<property name="orientation">
189+
<enum>Qt::Horizontal</enum>
190+
</property>
191+
</widget>
192+
</item>
193+
<item>
194+
<widget class="QLabel" name="volumnLabel">
195+
<property name="font">
196+
<font>
197+
<family>Consolas</family>
198+
</font>
199+
</property>
200+
<property name="text">
201+
<string>100</string>
202+
</property>
203+
</widget>
204+
</item>
205+
</layout>
206+
</item>
207+
</layout>
208+
</item>
209+
</layout>
210+
</item>
211+
</layout>
212+
</widget>
213+
<widget class="QMenuBar" name="menubar">
214+
<property name="geometry">
215+
<rect>
216+
<x>0</x>
217+
<y>0</y>
218+
<width>921</width>
219+
<height>26</height>
220+
</rect>
221+
</property>
222+
</widget>
223+
<widget class="QStatusBar" name="statusbar"/>
224+
</widget>
225+
<resources/>
226+
<connections/>
227+
</ui>

0 commit comments

Comments
 (0)