【发布时间】:2014-05-21 13:48:00
【问题描述】:
我想使用 QVideoWidget 或 QGraphicsVideoItem 在具有 Qt::FramelessWindowHint 标志和 Qt::WA_TranslucentBackground 属性的 QWidget 上播放电影。但视频不可见。我只听到声音。有什么问题?
编辑:
#include "videoplayer.h"
#include <QtWidgets/QApplication>
#include "qboxlayout.h"
#include "qvideowidget.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *w = new QWidget;
w->setWindowFlags(Qt :: Window | Qt::FramelessWindowHint );
w->setAttribute(Qt::WA_TranslucentBackground, true);
w->setMinimumSize(300,200);
QVideoWidget *videoWidget = new QVideoWidget;
QBoxLayout *controlLayout = new QHBoxLayout;
controlLayout->setMargin(0);
controlLayout->addWidget(videoWidget);
w->setLayout(controlLayout);
QMediaPlayer mediaPlayer;
mediaPlayer.setVideoOutput(videoWidget);
mediaPlayer.setMedia(QUrl::fromLocalFile("C:/1.wmv"));
videoWidget->show();
mediaPlayer.play();
w->show();
return app.exec();
}
【问题讨论】:
-
你能粘贴你的代码吗?
-
问题是编辑我有问题的代码。当两行 w->setWindowFlags(Qt :: Window | Qt::FramelessWindowHint ); w->setAttribute(Qt::WA_TranslucentBackground, true);正确删除电影节目。
标签: qt qwidget translucency