PDA

View Full Version : QVideoWidget can't show video in QGraphicsView in qt4.7.0 tp



vistb
8th April 2010, 11:08
Hi everyone, recently qt 4.7.0 tp has released and it intrtroduces a lot of new stuff. One thing i'm really exited about is that Qt now supports video playback natively by QMultimedia Module.

However, when i embed a QVideoWidget which connects to a QMediaPlayer into QGraphicsScene, the video just do not show up in the QGraphicsView while i do can hear the sound in the video?

Does anyone have a solution? Thanks a lot :)

the following is a part of my code:



class MovieInfoViewer : public QMainWindow
{
Q_OBJECT

public:
MovieInfoViewer(QWidget *parent = 0, Qt::WFlags flags = 0);
~MovieInfoViewer();

private:
Ui::MovieInfoViewerClass ui;

QGraphicsScene* pMainScene;
QVideoWidget* pBackGroundVideoWidget;
QMediaPlayer* pBackGroundVideoPlayer;
};




MovieInfoViewer::MovieInfoViewer(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);

pMainScene=new QGraphicsScene();
pBackGroundVideoWidget=new QVideoWidget();
pBackGroundVideoPlayer=new QMediaPlayer();

pBackGroundVideoWidget->setMediaObject(pBackGroundVideoPlayer);

pBackGroundVideoPlayer->setMedia(QUrl::fromLocalFile("bTest.wmv"));
pBackGroundVideoPlayer->setVolume(100);
pBackGroundVideoPlayer->play();

pMainScene->addWidget(pBackGroundVideoWidget);

ui.mainView->setScene(pMainScene);
ui.mainView->show();
}