If QVideoWidget does not provide what you need directly, you can always customize the overlay.
The hierarchy of the main layout element will be something like ...
QWidget layout QVideoWidget subtitle_widget
In this case, the layout can be either QStackedLayout , using the stacking mode QStackedLayout::StackAll or QGridLayout , while the QVideoWidget and subtitle_widget tags are the same but with the correct z-order.
Transition using QGridLayout ...
auto *w = new QWidget; auto *l = new QGridLayout(w); auto *video_widget = new QVideoWidget; auto *subtitle_widget = new QLabel; subtitle_widget->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); subtitle_widget->setWordWrap(true); l->addWidget(video_widget, 0, 0); l->addWidget(subtitle_widget, 0, 0);
Subtitles, etc. can now be displayed simply by calling subtitle_widget->setText(...) at the appropriate time.
The same method can be easily extended to overlay other types of information.
source share