I have to write a simple video player that can display some subtitles,link or a picture(like on YouTube) in a certain time. I have no idea of how do display anything using QVideoWidget. I couldn't find any useful class to do it. Could you please give me some advices?
I did It your way but after i load any video QLabel disappears...
player->setVideoOutput(vw);
playlistView->setMaximumWidth(200);
playlistView->setMinimumWidth(300);
window = new QWidget;
Playerlayout = new QGridLayout;
subtitleWidget = new QLabel;
subtitleWidget->setMaximumWidth(1000);
subtitleWidget->setMaximumHeight(100);
subtitleWidget->setStyleSheet("QLabel {background-color : red; color
blue;}");
subtitleWidget->setAlignment(Qt::AlignCenter | Qt::AlignBottom);
subtitleWidget->setWordWrap(true);
subtitleWidget->setText("example subtitle");
Playerlayout->addWidget(vw,0,0);
Playerlayout->addWidget(subtitleWidget,0,0);
Playerlayout->addWidget(playlistView,0,1,1,2);
If
QVideoWidget
doesn't provide what you require directly then you could always set up an overlay.The basic layout item hierarchy would be something like...
In this case the layout could be either a
QStackedLayout
using stacking modeQStackedLayout::StackAll
or aQGridLayout
with both theQVideoWidget
and thesubtitle_widget
occupying the same cells but with the correct z-order.Going with the
QGridLayout
...Subtitles etc. can now be displayed simply by invoking
subtitle_widget->setText(...)
at the appropriate time.The same method can easily be extended to overlaying other types of information.