我正在尝试设计一个应用程序来播放多个视频(媒体)文件,并允许每个文件的用户修改功能(例如,视频的缩放,旋转,反转等)。我开始研究Phonon
,但在进入其中一段时间之后,在> = Qt5
中不再支持它(或其支持是可疑的)。所以我回去了,现在我正在看qtmultimedia - QMediaPlayer
。虽然我来自c#-WPF背景,但我已经做过一些关于Qt-C ++的早期工作。但是这一次我对我必须使用的小部件感到困惑和困惑。 QMediaPlayer
可以在QVideoWidget
,QGraphicsVideoItem
和QAbstractVideoSurface
上显示其输出(视频)。由于我需要旋转等功能,我相信我必须加入QGraphicsScene / View。
&LT 1为卤素;那么这个方法应该是什么?我这样做了:使用了QVideoWidget
- >通过QGraphicsProxyWidget
()将此内容添加到setWidget
(尽管setWidget
()需要QWidget
*,而QVideoWidget
并非来自QWidget
,因为我在Qt助手中看到 - 为什么这允许顺便说一下?) - >通过QGraphicProxyWidget
() - >将此QGraphicsScene
添加到addItem
在构建它时将此QGraphicsScene
添加到QGraphicsView
- >已通过QGraphicsView
()将QMainWindow
添加到setCentralWidget
。这样好吗?何时使用QGraphicsVideoItem
和QAbstractVideoSurface
?
&LT 2 - ;以下列方式添加多个QVideoWidget
时,我看不到任何视频或QVideoWidget
本身(我已经绘制以区分它)。我究竟做错了什么? (虽然有音频输出):
QVideoWidget *pVideoWidget1 = new QVideoWidget(0);
pVideoWidget1->setPalette(QPalette(QColor(255,0,0),QColor(0,255,0)));
QVideoWidget *pVideoWidget2 = new QVideoWidget(0);
pVideoWidget2->setPalette(QPalette(QColor(255,0,0),QColor(0,0,255)));
m_pMediaPlayer1 = new QMediaPlayer(this);
m_pMediaPlayer2 = new QMediaPlayer(this);
m_pMediaPlayer1->setVideoOutput(pVideoWidget1);
m_pMediaPlayer2->setVideoOutput(pVideoWidget2);
m_pCustomGraphicsProxy1 = new CustomGraphicsProxy(0); //this is just a class derived from QGraphicsProxyWidget to implement drag and drop of videos
m_pCustomGraphicsProxy2 = new CustomGraphicsProxy(0);
m_pCustomGraphicsProxy1->setWidget(pVideoWidget1);
m_pCustomGraphicsProxy2->setWidget(pVideoWidget2);
QGraphicsScene *pGraphicsScene = new QGraphicsScene(this);
QGraphicsLinearLayout *pGraphicsLinearLayout = new QGraphicsLinearLayout;
CustomGraphicsProxy* button = new CustomGraphicsProxy(0);
button->setWidget(new QPushButton); //this i can see
CustomGraphicsProxy* button1 = new CustomGraphicsProxy(0);
button1->setWidget(new QPushButton); //this i can see too
pGraphicsLinearLayout->addItem(button);
pGraphicsLinearLayout->addItem(m_pCustomGraphicsProxy1); //can't see
pGraphicsLinearLayout->addItem(m_pCustomGraphicsProxy2); //can't see
pGraphicsLinearLayout->addItem(button1);
CustomGraphicsProxy *temp = new CustomGraphicsProxy(0);
temp->setLayout(pGraphicsLinearLayout);
pGraphicsScene->addItem(temp);
temp->show();
m_pGraphicsView = new QGraphicsView(pGraphicsScene, this);
setCentralWidget(m_pGraphicsView);
QObject::connect(m_pCustomGraphicsProxy1, SIGNAL(sigNewFileDragDropped()), this, SLOT(sloPlayOnWindow1()));
QObject::connect(m_pCustomGraphicsProxy2, SIGNAL(sigNewFileDragDropped()), this, SLOT(sloPlayOnWindow2()));
//just for testing - this gives only audio no video can be seen
m_pMediaPlayer1->setMedia(QUrl::fromLocalFile("d:/z.avi"));
m_pMediaPlayer1->play();
&LT 3的密度;在我进一步研究之前,我是否在Qt中选择合适的工具来操纵我之前提到过的视频或者需要做些什么呢?