The video player
In the previous section, we have learned how to create an audio player. In this chapter, we will further improvise our program and create a video player using Qt and C++.
Designing a user interface for video players
The next example is that of the video player. Since QMediaPlayer
also supports video output, we can use the same user interface and C++ code from the previous audio player example, and just make some minor changes to it.
- First, open
project file (.pro)
and add in another keyword, calledmultimediawidgets
:
QT += core gui multimedia multimediawidgets
- Then, open up
mainwindow.ui
and add aHorizontal Layout
(name it asmovieLayout
) above the timeline slider. After that, right-click on the layout and selectMorph into
|QFrame
. We then set itssizePolicy
property toExpanding, Expanding
:

- After that, we set the QFrame's background to black color by setting its
styleSheet
property, like so:
background-color: rgb(0, 0, 0);
- The user interface should look something like the following...