1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include "widget.h"
#include <QApplication>
#include <QLabel>
#include <QMediaPlayer>
#include <QVBoxLayout>
#include <QVideoWidget>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *widget = new Widget;
QVBoxLayout *l = new QVBoxLayout;
QMediaPlayer* player = new QMediaPlayer;
QVideoWidget *videoWidget = new QVideoWidget;
player->setVideoOutput(videoWidget);
player->setMedia(QUrl::fromLocalFile("C:/myvideo.avi"));
l->addWidget(videoWidget, 1);
QLabel *label2 = new QLabel;
QPixmap pixmap2("C:/myimage.jpg");
label2->setPixmap(pixmap2.scaled(100, 100, Qt::KeepAspectRatio));
l->addWidget(label2);
widget->setLayout(l);
player->play();
widget->show();
return a.exec();
} |
Partager